This topic has been archived. It cannot be replied.
-
工作学习 / 专业技术讨论 / How to write a MySQL statement?A table has following two fields:
MyCategory int
MyDate datetime
How to select the one latest record for each MyCategory ?
Will following work?
select * from TableName group by MyCategory order by MyDate desc limt 0, 1
Thank you for your help.
-exception(违例);
2006-5-23
{260}
(#2987322@0)
-
select MyCategory, MAX(MyDate) as Max_MyDate from TableName group by MyCategory
-e_dragon(e_dragon);
2006-5-23
(#2987348@0)
-
It works. Thank you very much.
-exception(违例);
2006-5-23
(#2987367@0)