postgresql 错误:“选择”处或附近的语法错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20099442/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 01:12:16  来源:igfitidea点击:

ERROR: syntax error at or near "select"

sqldatabasepostgresql

提问by user2983258

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

但现在我需要从表中获取数据

回答by dasblinkenlight

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

以下是jaro(name1, name2)为所有名称对选择的方法:

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 clientstable.

此查询使用所谓的自交叉联接- 它从您的clients表中生成所有名称对。

回答by Andrei Nicusan

I think you want to do something like this:

我想你想做这样的事情:

SELECT name, jaro(name, name)
FROM clients limit 50

Right? Or which are the columns you want to pass to jaro()?

对?或者您想传递给哪些列jaro()