get last sent message by users [closed]

Bolisaris

New Member
I need to write a query to retrieve values from two columns using mysql tableMy table has the following strucutre\[code\]| ID | to_user_id | from_user_id | message | datetime | | 1 | 21 | 07 | hi | 2012-05-10 04:13:01 | | 2 | 07 | 21 | hello | 2012-05-10 04:17:51 | | 3 | 21 | 11 | what's up | 2012-05-10 04:21:51 || 4 | 21 | 02 | hi dude | 2012-05-10 04:43:51 |\[/code\]I want to write a query to get only latest message from all from_user_id'si will try with \[code\]$query="select * from messages WHERE datetime = (SELECT MAX(datetime) FROM messages)";\[/code\]but it has error shownUnknown column 'datetime' in 'where clause'
 
Back
Top