[thelist] mySQL- how to test if table contains data
Richard Bennett
richard.b at gritechnologies.com
Wed Feb 6 03:30:01 CST 2002
Hi,
I am a mySQL beginner, doing someone else's work right now.
What I have is a table that stores (lots of) data per date.
I want to query the database, to know which days have data in them, at the
moment I load all the data for one month, and loop through it to see which
dates are in use - very inefficient of course.
How can I best query the database to know if a date is in use, without
extracting all the data at the same time?
I'm using Perl/mySQL
the current SQL is:
$sql="SELECT * FROM $database.$timetable WHERE Truckip like '$truckip' and
TIME<=$timeto AND TIME>=$timefrom order by TIME";
Where $timeto and $timefrom cover a 1 month segment.
Any ideas?
Richard.
More information about the thelist
mailing list