我有三个表,每个表都有一个外键。当我执行连接时,我得到重复的列。
给定
mysql> describe Family;
+---------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+-------------+------+-----+---------+-------+
| HEAD_name | varchar(45) | NO | PRI | | |
| Family_Size | int(11) | NO | | | |
| Gender | char(1) | NO | | | |
| ID_Number | int(11) | NO | | | |
| DOB | date | NO | | | |
| Supervisor_ID | int(11) | NO | MUL | | |
+---------------+-------------+------+-----+---------+-------+
6 rows in set (0.00 sec)
mysql> describe SUPERVISOR;
+-------------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+---------------+------+-----+---------+-------+
| Supervisor_ID | int(11) | NO | PRI | | |
| Supervisor_Name | varchar(45) | NO | | | |
| Supervisor_Number | decimal(10,0) | NO | | | |
| Center_ID | int(11) | NO | MUL | | |
+-------------------+---------------+------+-----+---------+-------+
4 rows in set (0.00 sec)
mysql> describe CENTER;
+-----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+-------------+------+-----+---------+-------+
| Center_ID | int(11) | NO | PRI | | |
| Location | varchar(45) | NO | | | |
+-----------+-------------+------+-----+---------+-------+
2 rows in set (0.00 sec)
我的查询语句:
SELECT * from Family
JOIN SUPERVISOR on ( Family.Supervisor_ID = SUPERVISOR.Supervisor_ID)
JOIN CENTER on (SUPERVISOR.Center_ID = CENTER.Center_ID);
我的目标是从连接中获取所有列中的一行,而没有重复的列。那么我应该使用什么 SQL 语句语法呢?