Postgresql 检查一个属性是否是另一个属性的子字符串而不考虑大小写
Postgresql check if an attribute is a substring of another attribute regardless of case
如果登录名是名称的子字符串(不区分大小写),我想显示属性登录名、姓名、性别、地址和从 table 播放器加入
例如,
如果登录名是 'thom' 并且名称是 'Thomas' 查询应该 return 这个元组
如果登录名是 'qw' 并且名称是 'Sarah' 那么查询不应该 return 这个元组
下面的查询是我到目前为止的查询,我已经尝试使用 LIKE 和 SIMILAR 以及子字符串,但我无法弄明白
select login, name, gender, address, joined
from Player
where login ~* name
if login is 'thom' and the name is 'Thomas' the query should return this tuple
您似乎希望模式以相反的方式匹配:
where name ~* login
你也可以用 ilike
来表达:
where name ilike '%' || login || '%'
如果登录名是名称的子字符串(不区分大小写),我想显示属性登录名、姓名、性别、地址和从 table 播放器加入 例如, 如果登录名是 'thom' 并且名称是 'Thomas' 查询应该 return 这个元组 如果登录名是 'qw' 并且名称是 'Sarah' 那么查询不应该 return 这个元组
下面的查询是我到目前为止的查询,我已经尝试使用 LIKE 和 SIMILAR 以及子字符串,但我无法弄明白
select login, name, gender, address, joined
from Player
where login ~* name
if login is 'thom' and the name is 'Thomas' the query should return this tuple
您似乎希望模式以相反的方式匹配:
where name ~* login
你也可以用 ilike
来表达:
where name ilike '%' || login || '%'