Hi,
I'm looking for the most efficient way to know if a table isn't empty. So far, I just queried it, gathered the result and checked if it was empty or not.
Is there a more efficient way to do it?
Regards,
-jj. :)
Printable View
Hi,
I'm looking for the most efficient way to know if a table isn't empty. So far, I just queried it, gathered the result and checked if it was empty or not.
Is there a more efficient way to do it?
Regards,
-jj. :)
SELECT COUNT(*) FROM daTable
alternatively,
SELECT acolumn FROM daTable LIMIT 1
select count(*) from datable is best for myisam tables and can be horrible for innodb, but select acolumn from datable limit 1 is very good for myisam tables and best for innodb tables.
so use the second form.
how about
Is there any difference over cout(*)?Code:select top 1 myColumn from myTable
yes, there is a difference
also, TOP doesn't work in mysql
:)