gpt4 book ai didi

MySQL检查是否存在多行

转载 作者:行者123 更新时间:2023-11-29 01:29:37 26 4
gpt4 key购买 nike

Here you can find how to check row existance:
SELECT EXISTS(SELECT 1 FROM table1 WHERE some_condition);

如何从表中有效地存在多行:

SELECT EXISTS(SELECT 1 FROM table1 WHERE key = 0);
SELECT EXISTS(SELECT 1 FROM table1 WHERE key = 2);

来自表格:

key,username
0,foo
1,bar
2,boo

仅当找到两行(具有键 0 和 2)时才返回正数?

最佳答案

SELECT count(distinct key) = 2  FROM table1 WHERE key in (0, 2) 

关于MySQL检查是否存在多行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20334845/

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