ERROR: syntax error at or near "select"

15,858

Here is how you can select jaro(name1, name2) for all pairs of names:

SELECT
    t1.name as name1
,   t2.name as name2
,   jaro(t1.name, t2.name) as jaro
FROM
   (select name from clients limit 50) t1
CROSS JOIN
    (select name from clients limit 50) t2

This query uses a so-called self cross join - it produces all pairs of names from your clients table.

Share:
15,858
user2983258
Author by

user2983258

Updated on June 04, 2022

Comments

  • user2983258
    user2983258 almost 2 years

    This code gave me an ERROR: syntax error at or near "select"

    SELECT name_one, name_two, jaro(
       select name from clients limit 50 as name_one, 
       select name from clients limit 50 as name_two
    );
    

    This works fine:

    select jaro('aaa','aaa');
    

    But now i need to get data from tables

  • Sergey Kalinichenko
    Sergey Kalinichenko over 10 years
    @user2983258 Apart from the call of your jaro function which you said works fine for you, the query should be fine (see its shortened version on sqlfiddle).
  • Sergey Kalinichenko
    Sergey Kalinichenko over 10 years
    @user2983258 You are right, I was missing a FROM in the post (the demo included it, though).