连接时重复列

时间:2017-03-23 23:12:50

标签: mysql join mysql-error-1060

我尝试连接三个表,然后将一个表过滤到每个用户的最新条目。但是,我突然遇到了错误promise。我需要加入这个"复制"柱。我该如何解决这个问题?

.then

1 个答案:

答案 0 :(得分:2)

*中,您有两列username。您需要限定其中一个或两个。示例如下:

SELECT 
   customers.id,customers.name,customers.username,customers.phone,customers.email,radcheck.value as password
        FROM customers
        RIGHT JOIN radcheck ON customers.username = radcheck.username
        LEFT JOIN (
                SELECT radrecent.username, latest FROM radacct INNER JOIN (
                     --^^^^^^^^^
                    SELECT username,MAX(acctupdatetime) AS latest FROM radacct GROUP BY username
                ) as radrecent 
                ON radacct.username = radrecent.username 
                AND radacct.acctupdatetime = radrecent.latest
        ) as radlatest 
            ON customers.username = radlatest.username
        WHERE radcheck.attribute = 'Cleartext-Password'