返回空值IN子句mysql

返回空值IN子句mysql,第1张

返回空值IN子句mysql

您需要使用其他方法。您将需要使用UNIOn ALL创建具有所有值的内联视图,然后将其与users表保持连接:

SQL小提琴

查询1

SELECt a.uid, (CASE WHEN (u.uid is null) THEN 'not found' ELSE 'found' END) as     resultFROM (select 1 as UID FROM dual      UNIOn ALL      select 2 as UID FROM dual      UNIOn ALL      select 56443 as UID FROM dual      UNIOn ALL      select 3 as UID FROM dual) as aLEFT JOIN users u on a.uid = u.uid

[结果]

|   UID |    result ||-------|-----------||     1 |     found ||     2 |     found ||     3 |     found || 56443 | not found |


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5643055.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存