在 PSQL v11 的 Where 子句中连接两列

Concat two columns in Where Clause in PSQL v11

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

The above works but my input parameter would have a space in it for example "John Smith". I tried adding

 WHERE Person = ltrim('John Smith')

但这也不起作用。

就像这样:

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

查询:

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

不会 return 任何记录,因为 space 而您正在 rtrim 字段。
你可以使用类似的东西:

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

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