在PSQL v11中Where子句中的Concat两列

时间:2017-04-05 18:12:52

标签: pervasive

SELECT CONCAT(rtrim(Xyz.FirstName), rtrim(Xyz.LastName)) as person from Xyz
WHERE Person = ('JohnSmith')
  

以上工作但我的输入参数中有一个空格   例子" John Smith"。我尝试添加

 WHERE Person = ltrim('John Smith')

但这也不起作用。

2 个答案:

答案 0 :(得分:0)

查询:

SELECT CONCAT(rtrim(Xyz.FirstName), rtrim(Xyz.LastName)) as person from Xyz
WHERE Person = ('Jon Smith')

由于空间而无法返回任何记录,而您rtrim字段 你可以使用类似的东西:

SELECT CONCAT(rtrim(Xyz.FirstName), concat(' ', rtrim(Xyz.LastName))) as person from Xyz
WHERE Person = ('Jon Smith')

请注意concat部分中的额外Select和空格('')。

答案 1 :(得分:-1)

就像这样:

select * from person where trim(last_name)||trim(first_name)= replace('John  Smith', ' ', '')