I\'m trying to find out if a row exists in a table. Using MySQL, is it better to do a query like this:
SELECT COUNT(*) AS total FROM table1 WHERE ...
At times it is quite handy to get the auto increment primary key (id) of the row if it exists and 0 if it doesn't.
id
0
Here's how this can be done in a single query:
SELECT IFNULL(`id`, COUNT(*)) FROM WHERE ...