Query Problem

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

Query Problem

Post by itsmani1 »

Hello,

I am having a query problem. this query is not returning correct tm value.

It returns tm value of row one with row two etc. I think I need to put a condition where it calculate tm with correct row but i don't know how can i do this.

Here is query
select TIME_FORMAT(TIMEDIFF(now(),p.created),'%H')as tm, p.price from prices p where p.FK_STATION_ID in (1,2,3) and p.FK_CITY_ID in (1,2,20,4,5,6,7,8) and p.created > DATE_ADD(now() ,INTERVAL -24 hour) order by p.PK_ID desc
Thanks.
Post Reply