mysql查询在同一个表上执行多个内部联接

时间:2014-03-20 11:08:24

标签: mysql sql inner-join

我需要在同一个表上执行多个连接。以下是我的查询。 当我执行以下查询时,它为我提供了单个列的重复记录。 谁能告诉我哪里出错?

$result=mysql_query("SELECT DISTINCT *,CONCAT(phno, ' ', vnumber) AS source,CONCAT(phno, ' ', vnumber) AS destination FROM gcm_users as gu
                                                INNER JOIN message_Log as ml1 ON gu.imei= ml1.Source_ID 
                                                INNER JOIN message_Log as ml2 ON gu.imei= ml2.Destination_ID
                                                WHERE  gu.id={$_SESSION['uid']}");

1 个答案:

答案 0 :(得分:0)

您可以用一个

替换2个连接
INNER JOIN message_Log as ml1 ON gu.imei= ml1.Source_ID 
        OR gu.imei= ml2.Destination_ID