Mysql
 sql >> Base de Dados >  >> RDS >> Mysql

Coluna duplicada na junção


No * você tem duas colunas que são username . Você precisa qualificar um ou ambos. Exemplo abaixo:
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'