gpt4 book ai didi

sql - WHERE col1, col2 IN 中的 Postgres 多列

转载 作者:行者123 更新时间:2023-11-29 12:04:32 24 4
gpt4 key购买 nike

我可以轻松做到:

select * from cities where name in ('Paris', 'London');

但是我也可以选择具有列组合的行吗?

从城市、国家位于 (('Paris', 'France'), ('London', 'UK')) 的城市中选择 *

最佳答案

是的,但你必须使用括号:

select * from cities where (city, country) in (('Paris', 'France'), ('London', 'UK'))

语法是“复合值”的语法。查看manual :

The external text representation of a composite value consists of items that are interpreted according to the I/O conversion rules for the individual field types, plus decoration that indicates the composite structure. The decoration consists of parentheses (( and )) around the whole value, plus commas (,) between adjacent items.

关于sql - WHERE col1, col2 IN 中的 Postgres 多列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34029080/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com