Friday, January 30, 2015

[SQL][Resolved] Syntax error or access violation: 1066 Not unique table/alias: xxxx


if you got this error message, try double check if you have ever joined any table grades to itself, there is an example:



select * from `a_branches`
left join `a_branches` on `a_branches`.`agency_ref` = `a_agencies`.`agency_id`
left join `ab_addresses` on `a_branches`.`branch_id` = `ab_addresses`.`branch_ref`
where `a_branches`.`branch_id` = 8
it joined the table "a_branches" to itself.
The solution is edit that tables name:
select * from `a_agencies`
left join `a_branches` on `a_branches`.`agency_ref` = `a_agencies`.`agency_id`
left join `ab_addresses` on `a_branches`.`branch_id` = `ab_addresses`.`branch_ref`
where `a_branches`.`branch_id` = 8

 
Reference:
http://stackoverflow.com/questions/2077355/mysql-php-not-unique-table-alias

No comments :

Post a Comment