1066 - 不唯一的表/别名:

时间:2015-11-24 05:49:02

标签: mysql sql

你能帮我解决一下吗?我有这个SQL查询:

SELECT `a`.`UNIQ_CODE`, `b`.`JUDUL_BERITA`, `b`.`THUMNAIL`, `c`.`NAMA`, 
       `a`.`TAG`, `a`.`CREATED_DATE`, `a`.`GLOBAL`, `a`.`VERIFIKASI` 
FROM (`q_master_berita` a) 
JOIN `q_master_berita` a ON `b`.`UNIQ_CODE` = `a`.`UNIQ_CODE` 
RIGHT JOIN `q_daftar_user` c ON `a`.`ID_UPLOADER` = `c`.`ID` 
WHERE ( a.FLAG = 'DRAFT' AND a.ID_SEKOLAH = '3824' ) 
ORDER BY `b`.`JUDUL_BERITA` asc 
LIMIT 10

不知何故,它说

Not unique table/alias: 'a'

1 个答案:

答案 0 :(得分:0)

那是因为你对表q_master_berita使用了两次相同的别名。您需要使用不同的别名。

SELECT `a`.`UNIQ_CODE`, `b`.`JUDUL_BERITA`, `b`.`THUMNAIL`, `c`.`NAMA`, 
   `a`.`TAG`, `a`.`CREATED_DATE`, `a`.`GLOBAL`, `a`.`VERIFIKASI` 
FROM (`q_master_berita` a) 
JOIN `q_master_berita` b ON `b`.`UNIQ_CODE` = `a`.`UNIQ_CODE` 
RIGHT JOIN `q_daftar_user` c ON `a`.`ID_UPLOADER` = `c`.`ID` 
WHERE ( a.FLAG = 'DRAFT' AND a.ID_SEKOLAH = '3824' ) 
ORDER BY `b`.`JUDUL_BERITA` asc 
LIMIT 10