Why does this query errors (1060) Duplicate column name 'studentID'
in MySQL? How can I prevent it?
CREATE TEMPORARY TABLE tempTable
select * from member_infos
join contact_infos on member_infos.studentID=contact_infos.studentID
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.