DelphiFAQ Home Search:
General :: Databases :: mysql
General information about mysql - how to get around the differences between version 3.33 an 4, how to do stuff that you think you need a nested query for etc.

Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Featured Article

count(*) syntax in mysql

You may be surprised to find out that there is no white space allowed between count and () in mysql queries.

Also be careful on which column you perform the count. It may not be wise to use count(*) if you have a certain index defined and you have a where condition that uses this index. You might want to replace the '*' with a column name. Read more on this bug here:

http://bugs.mysql.com/bug.php?id=14980

// ERROR 1064 (42000): You have an error in your SQL syntax;
 // check the manual that corresponds to your MySQL server version for the right
 // syntax to use near '(*) from table1' at line 1
 select count (*) from table1;
 
 // the next one works:
 select count(*) from table1;

Generated 4:00:42 on Apr 25, 2017