【发布时间】:2015-12-02 04:13:07
【问题描述】:
我可以轻松做到:
select * from cities where name in ('Paris', 'London');
但我也可以选择包含列组合的行吗?
select * from cities where city, country in (('Paris', 'France'), ('London', 'UK'))
【问题讨论】:
标签: sql postgresql
我可以轻松做到:
select * from cities where name in ('Paris', 'London');
但我也可以选择包含列组合的行吗?
select * from cities where city, country in (('Paris', 'France'), ('London', 'UK'))
【问题讨论】:
标签: sql postgresql
是的,但你必须使用括号:
select * from cities where (city, country) in (('Paris', 'France'), ('London', 'UK'))
语法是“复合值”的语法。见manual:
复合值的外部文本表示由根据各个字段类型的 I/O 转换规则解释的项目以及指示复合结构的装饰组成。装饰由整个值周围的括号((和))以及相邻项之间的逗号(,)组成。
【讨论】: