【发布时间】:2016-02-03 14:18:45
【问题描述】:
假设我有一个名为 tt 且 ID 为 1,2 的表
我想搜索以下所有 1,2,3
当我使用select id from tt where id in (1,2,3)
我得到 1 和 2 的结果
但是如果我需要显示我搜索的所有内容(如果存在)或什么都不显示怎么办?
提前谢谢你
【问题讨论】:
-
使用如果存在,count() ... where id = 1 > 0 and count() ... where id = 2 > 0 and count(*) 。 .. where id = 1 > 0 ... 然后选择 select ... else return 'Nothing found' :)
标签: mysql sql where-clause mariadb where-in