Skip to content
Advertisement

MySQL error with Not unique table/alias with join

SELECT `idstudii` 
FROM (`studii`) 
JOIN `studii` ON `mesaje`.`idstudii`=`studii`.`id` 
JOIN `users` ON `users`.`id`=`studii`.`idusers` 
WHERE `studii`.`idusers` = '1'

I have this sql query which gives me the error “Not unique table/alias”. This is not the case as “studii” is the only table with that name. Why does this error show up?

Advertisement

Answer

FROM (`studii`) 
JOIN `studii`

in this care you are referring to 2 different selections of a table with the same alias (studii)

FROM `studii` AS s1
JOIN `studii` AS s2 ON s2.something2 = s1.something1
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement