Matin Lotfaliee Matin Lotfaliee - 1 year ago 142
MySQL Question

#1060 - Duplicate column name

Why does this query errors

(1060) Duplicate column name 'studentID'
in MySQL? How can I prevent it?

select * from member_infos
join contact_infos on member_infos.studentID=contact_infos.studentID

Answer Source

If you use MySQL's USING clause (alternative to ON), it will only product one copy of the shared field used to join those tables in the results of the SELECT.

If there are other fields sharing names, USING cannot help you; you will need to list out all fields explicitly in order to exclude (or alias) fields with the same name.

USING is covered in the MySQL JOIN documention.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download