用mysql INNER JOIN命令

时间:2015-12-04 13:14:06

标签: php mysql

我从内部联接的两个表中获取记录,但是我没有得到正确的结果。

这是我的代码:

   real_query = "SELECT DISTINCT user.id AS uid, user.name AS unm, user.profile_pic AS upic, user_message.message_by_id AS message_by_id
                 FROM user INNER JOIN
                      user_message
                      ON user.id = user_message.message_by_id 
                 where (user_message.message_to_id = '".$sess."' AND 
                        user_message.receiver_deleted = 'No')
                 group by user_message.id, user_message.sent_on
                 order by user_message.id DESC ";

问题是,我想回复用户表中的那些用户名,按user_message.id排序,但我没有得到我想要的结果。

0 个答案:

没有答案