Mysql query

Hi Everybody I have a table called mail which is as follows:

id user_id message_id conversation_id created_at
== ===== ========= =========== =================
22 2 12 10 2008-07-17
18:18:38
23 3 12 10 2008-07-17 18:18:39
24 1 12 10 2008-07-17 18:18:39
25 2 13 10 2008-07-17 18:29:16
26 1 13 10 2008-07-17 18:29:16
27 3 13 10 2008-07-17 18:29:17
28 1 14 11 2008-07-17 19:23:09
29 3 14 11 2008-07-17 19:23:10
30 2 14 11 2008-07-17 19:23:09

Now i want only those unique tuples whose conversation_id are same but
out of it I want the latest i.e order by created_at desc. but I want
all attributes.
This is what I want for as an output

id user_id message_id conversation_id created_at
== ===== ========= =========== =================
27 3 13 10 2008-07-17 18:29:17
29 3 14 11 2008-07-17 19:23:10

U can do like.

conversation_ids << [10,11]
for conversation in conversation_id
@my_mail << Mail.find(:last,:conditions =>
[‘conversation_id=?’,conversation])
end

i hope it will work :slight_smile:

thank for your reply. I resolved it in the similar fashion.

On Jul 18, 11:09 am, “bala kishore pulicherla” [email protected]