I am using PHP & MySQL for a program that I am writing. I have a table in my database that has a column with dates in it in the form yyyy-mm-dd. Sometimes there is nothing in the table with the search date that I am using. Other times there might be 1000's of rows with that in the date column. I am trying to find out if there are any rows with the date that I am searching for in the 'date' column. Would the fastest way be to use
$date=2003-02-16;
SELECT COUNT(*) FROM `games` WHERE `date`='$date'
or is there a faster way?
You might try
SELECT 1 FROM `games` WHERE `date`='$date' LIMIT 1
and then see if you get a row back. LIMIT allows MySQL to perform some optimizations (such as terminating query processing once it finds enough matching records).
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]
-- Paul DuBois, Senior Technical Writer Madison, Wisconsin, USA MySQL AB, www.mysql.com
Are you MySQL certified? http://www.mysql.com/certification/
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]