mysql判断某一条数据是否存在于某个表中

mysql判断某一条数据是否存在

方式一:

SELECT IFNULL((SELECT 'Y' from classification_question where question_id = 2 limit 1),'N')

方式二:

SELECT case WHEN COUNT(*) > 0 THEN 'Y' else 'N' END from classification_question WHERE question_id = 200 LIMIT 1

 


版权声明:本文为susu1083018911原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。