MySQL Removing duplicate columns on Left Join, 3 tables

后端 未结 4 469
时光取名叫无心
时光取名叫无心 2020-12-06 05:42

I have three tables, each have a foreign key. When I perform a join, I get duplicate columns.

Given

mysql> describe Family;
+---------------+----         


        
4条回答
  •  悲哀的现实
    2020-12-06 06:18

    You are not getting duplicate columns, what you are really getting is the Supervisor_ID column from table Family (that is Family.Supervisor_ID) and Supervisor_ID from table Supervisor (that is Supervisor.Supervisor_ID) but to your result set, you will see both as Supervisor_ID, and that is why you think they are duplicated. The same will happen with Center_iD.

    The solution is to specify the fields that you need from each table, and decide if you need to get the Supervisor_ID and Center_ID and which table to get it from.

提交回复
热议问题