[thelist] mySQL- how to test if table contains data
Richard Bennett
richard.bennett at skynet.be
Fri Feb 8 03:44:01 CST 2002
Hi,
Thanks Phil and Benji.
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";
If I simply do this:
$sql="SELECT TIME FROM $database.$timetable WHERE Truckip like '$truckip'
";
It returns all the unix-timestamps as expected.
It's just grouping these per day, that doesn't want to work, it returns no
records.
Thanks for all the help.
Cheers,
Richard.
----- Original Message -----
From: "BT Bigpant" <bigpant at btinternet.com>
could be, I know FROM_UNIXTIME(unix_timestamp, format) works.
Try the format as "%Y-%m-%d". That should give 2002-02-06 for today. As long
as you use Ymd, you will get the year, month and day, ignoring hours, mins &
secs.
HTH
Phil Parker
> Would it be possible to "GROUP BY " day, when the date-format is in
> Unix-time (sec since 1970) ?
you can do this:
select ... ,TO_DAYS(timestamp) as date_day where ... group by date_day
i think? i know that works with a mysql timestamp - don't know if it works
with a unix timestamp... can anyone clarify?
benji.
inchima.com
More information about the thelist
mailing list