[thelist] mySQL- how to test if table contains data

Ben Phillips ben at inchima.com
Fri Feb 8 05:20:00 CST 2002


> I was not successful in getting this working though, probably due
> to my lack
> of basic SQL knowledge. What I came up with was this:
>
>   $sql="SELECT TO_DAYS(FROM_UNIXTIME(TIME,'%Y-%m-%d')) as date_day FROM
> $database.$timetable WHERE Truckip like '$truckip' group by date_day";

FROM_UNIXTIME without the date format string (ie. '%Y-%m-%d') produces a
DATETIME format than you can use with FROM_UNIXTIME.

example:
SELECT TO_DAYS(FROM_UNIXTIME(TIME)) as date_day FROM ....

i haven't tested this, so please forgive me if there is something
fundamentally wrong here. also, check you are definitely storing unix
timestamps and not mysql timestamps...

benji
inchima.com




More information about the thelist mailing list