You are here

21 September 2016

If you need to show user different content whether a table is empty or not. So you would need to count table rows for that. Counting every row will iterate through the table rows and is really slow. The best method would be to get the first row from the table, if it exists the table has results and vice versa. You can ever more optimize this with selecting NULL, that eliminates the need of reading column data.

Source code viewer
  1. SELECT NULL FROM [table_name] LIMIT 1;
Programming Language: MySQL