-1

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

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?

thanks Kumar

Kumar Shanmugam
  • 597
  • 1
  • 11
  • 40

3 Answers3

2

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.

Paraíso
  • 384
  • 2
  • 8
2

you can write query like

SELECT IF(COUNT(*) >0, TRUE,FALSE)as response FROM <tablename> WHERE emailid='edf@dfg.com';
developerCK
  • 4,418
  • 3
  • 16
  • 35
1
select exists(
   SELECT 1 FROM <tableName> WHERE email LIKE 'abc@gmail.com'
)
mauretto
  • 3,183
  • 3
  • 27
  • 28