I have a problem with my SQL query. I want to display the last message for a user. So, i use the method "GROUP BY" but he don't display the LAST message.
This is my first query:
SELECT `messages`.*, `conversations`.*
FROM `messages` JOIN `conversations` ON `conversations`.`cNUM` = `messages`.`mCONV_NUM`
WHERE `cUSER2` = '2'
GROUP BY `messages`.`mCONV_NUMn`
I try to follow this subject: ORDER BY date and time BEFORE GROUP BY name in mysql (and a lot of other)
And i have this:
SELECT `messages`.*, `conversations`.*
FROM (SELECT mTIME
FROM `messages`
ORDER BY mTIME desc) AS M
JOIN `conversations` ON `conversations`.`cNUM` = `messages`.`mCONV_NUM`
WHERE `cUSER2` = '2'
GROUP BY `messages`.`mCONV_NUMn`
And i have this error: Table 'messages' unknown.
So.. i need your help guys