【发布时间】:2019-05-09 23:43:41
【问题描述】:
我是数据库编程的初学者。我正在做我的作业,我得到了一个关于 sql 查询的任务。我的任务是在一个句子中合并一个表(人)的 3 列(名字、姓氏、性别)。
例如:
"John Anderson is a male."
"Julia Smith is a female."
我写了以下查询:
SELECT first_name, last_name, ||' is a '|| sex ||'.'||
FROM person
LIMIT 10
我得到这个错误:
ERROR: Operator does not exist: text ||
LINE 1:select first_name, last_name, ||' is a '|| sex ||'.'||
^
HINT: No operator matches the specified name and argument type. You may have to add explicit type conversions.
如果有人能给我一个想法或解决方案,那对我来说会很棒。
【问题讨论】:
-
您使用的是什么 DBMS? MySQL、PostgreSQL、SQL Server、甲骨文???
-
我认为类似于
select first_name + ' ' + last_name + ' is a ' + sex from person limit 10,至少在sql server中。 -
我在 pgAdmin 平台中使用 PostgreSQL
-
也许这个错误是因为你不需要最后一个 ||在你的句子中。
标签: sql database string select selection