this question has answer here:
- fetch row has max value column 32 answers
i have 3 queries:
select `update`.`id` `id`, `update`.`type` `type`, `update`.`date` `date`, `update`.`like` `like`, `update`.`dislike` `dislike` `updates` `update` `type` = '1' order `date` desc limit 1 select `update`.`id` `id`, `update`.`type` `type`, `update`.`date` `date`, `update`.`like` `like`, `update`.`dislike` `dislike` `updates` `update` `type` = '2' order `date` desc limit 1 (1) select `update`.`id` `id`, `update`.`type` `type`, `update`.`date` `date`, `update`.`like` `like`, `update`.`dislike` `dislike` `updates` `update` `type` = '3' order `date` desc limit 1 (1)
i need last date each type. how can in 1 query?
thank you.
this must #1 common mysql question.
select u.* update u join (select type, max(date) maxdate update type in ('1', '2', '3') group type) m on u.type = m.type , u.date = m.maxdate
Comments
Post a Comment