是否有任何SQL查询来检查值是否存在或不存在于数据库表中 [英] Is there any sql-query to check the value is exist or not in db table
问题描述
在我的数据库表中具有此值,我必须检查此电子邮件值'abc@gmail.com'是否存在于数据库中.
In my database table have this value,i have to check this email value 'abc@gmail.com' is exist in the database or not.
abc@gmail.com
edf@dfg.com
xyz@abcinfo.com
12345@fdfg.com
如果数据库表中存在'abc@gmail.com'值,则输出为true,否则为false,那么如何编写查询以实现此目的?
If 'abc@gmail.com' value is exist in the database table, output is true else false, so how to write the query for this to achieve?
谢谢 库马尔
推荐答案
您可以做一些简单的事情
select CASE WHEN count(1) > 0 THEN 'true' ELSE 'false' END from table where email = 'abc@gmail.com'
You can do something as simple as
select CASE WHEN count(1) > 0 THEN 'true' ELSE 'false' END from table where email = 'abc@gmail.com'
但是您应该提供更多信息,以获得更出色的答案.
But you should give some more information for a beater answer.
这篇关于是否有任何SQL查询来检查值是否存在或不存在于数据库表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!