sql >> Databasteknik >  >> RDS >> Mysql

få senaste textinmatningen av GROUP BY-satsen

Prova detta-

SELECT *, MAX(conversations_mails.created_on) As conversation_last_reply,
  MAX(conversations_mails.id) AS maxId
FROM conversations 
LEFT JOIN conversations_mails ON conversations_mails.conversation_id = conversations.id 
WHERE conversations_mails.id = (select max(conversations_mails.id) from conversations_mails where conversations_mails.conversation_id = conversations.id)
GROUP BY conversations.id 
ORDER BY conversation_last_reply DESC


  1. mysql_connect VS mysql_pconnect

  2. mysql VAR MATCH MOT

  3. Minska värdet i mysql men inte negativt

  4. Deklarera en variabel i en "skrivskyddad" MySQL-databas