
Originally Posted by
r937
Code:
select *
from Item as o
where dateadded
= ( select max(dateadded)
from Item
where categoryid = o.categoryid )
limit 10
Ok thanks, it worked out well,
that good 'old max() always forgetting that one 
final query looks like this.. quite slow one :s
(working with more than 1 category for an item )
Code:
"select ic.categoryid,i.itemid,i.name,i.urlname,location,dateadded
from items i
inner join itemcategory ic on i.itemid=ic.itemid
inner join categories c on ic.categoryid=c.id
where categorytype=$categoryType
and dateadded =( select max(dateadded)
from items i2
inner join itemcategory ic2 on i2.itemid=ic2.itemid
where ic2.categoryid=ic.categoryid )
order by dateadded desc
limit 0,$offset"
Well I wonder if this will work for mysql < 4.1..
only tested it out on 4.1.. but my production server is 4.0
let's hope there's no need to rewrite it as a join
Bookmarks