Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果查询完成,我有这段代码显示“1”,当查询为空时如何显示“0”。
SELECT 1 as 'access' FROM `mytable` WHERE `name` = 'Prophet Muhammad' and id = 1;
利用COUNT
COUNT
SELECT (COUNT(*) >= 1) as 'access' FROM mytable WHERE name = 'Prophet Muhammad' and id = 1;
您可以使用它,当查询返回至少一行时显示 1,否则显示 0:
SELECT EXISTS (SELECT Null FROM `mytable` WHERE `name` = 'Prophet Muhammad' and id = 1) as Status