I think: change "id" to visitor_id If it still doesn't work, make sure date_sub and created are of the same type -- created must be in "yyyy-mm-dd hh:mm:ss" format (datetime type) in order for that to work; the > might even fail (can't remember). why not do ... where unix_timestamp(visitors.created)>unix_timestamp(date_sub(NOW(), INTERVAL 1 HOUR)) and ... Peter; it's friday, I can't remember things On Fri, 11 Jul 2003, Mike Mannakee wrote: > I am running a query in mysql : > > SELECT DISTINCT (id) AS visitor_id, > MAX(date_time) AS last, > MIN(date_time) AS first, > UNIX_TIMESTAMP( MAX(date_time)) - > UNIX_TIMESTAMP( MIN(date_time)) AS diff > FROM visitors, pixeldata_ > WHERE > visitors.created > DATE_SUB( CURRENT_DATE, INTERVAL 1 HOUR ) > AND > id = pixeldata_.remote > GROUP BY > visitors.id > > The idea behind the WHERE clause is to only get results from the last hour. > I have used this construct successfully in dozens of other queries. > However, the results here are giving me every single visitor in the table. > Regardless of when created. > > In other words that part of the WHERE clause is not working. Does anybody > see any problem in the sql that I'm not seeing?? This is driving me nuts. > > Mike > > > > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > --------------------------------------------------------------------------- Peter Beckman Internet Guy beckman@purplecow.com http://www.purplecow.com/ --------------------------------------------------------------------------- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php