<small id='nz2Lm'></small><noframes id='nz2Lm'>

    1. <i id='nz2Lm'><tr id='nz2Lm'><dt id='nz2Lm'><q id='nz2Lm'><span id='nz2Lm'><b id='nz2Lm'><form id='nz2Lm'><ins id='nz2Lm'></ins><ul id='nz2Lm'></ul><sub id='nz2Lm'></sub></form><legend id='nz2Lm'></legend><bdo id='nz2Lm'><pre id='nz2Lm'><center id='nz2Lm'></center></pre></bdo></b><th id='nz2Lm'></th></span></q></dt></tr></i><div id='nz2Lm'><tfoot id='nz2Lm'></tfoot><dl id='nz2Lm'><fieldset id='nz2Lm'></fieldset></dl></div>
      <legend id='nz2Lm'><style id='nz2Lm'><dir id='nz2Lm'><q id='nz2Lm'></q></dir></style></legend>
    2. <tfoot id='nz2Lm'></tfoot>

          <bdo id='nz2Lm'></bdo><ul id='nz2Lm'></ul>

      1. MySQL删除左连接上的重复列,3个表

        时间:2023-10-09
        <legend id='yVNrf'><style id='yVNrf'><dir id='yVNrf'><q id='yVNrf'></q></dir></style></legend>

        <small id='yVNrf'></small><noframes id='yVNrf'>

          <tbody id='yVNrf'></tbody>

            <bdo id='yVNrf'></bdo><ul id='yVNrf'></ul>
              <i id='yVNrf'><tr id='yVNrf'><dt id='yVNrf'><q id='yVNrf'><span id='yVNrf'><b id='yVNrf'><form id='yVNrf'><ins id='yVNrf'></ins><ul id='yVNrf'></ul><sub id='yVNrf'></sub></form><legend id='yVNrf'></legend><bdo id='yVNrf'><pre id='yVNrf'><center id='yVNrf'></center></pre></bdo></b><th id='yVNrf'></th></span></q></dt></tr></i><div id='yVNrf'><tfoot id='yVNrf'></tfoot><dl id='yVNrf'><fieldset id='yVNrf'></fieldset></dl></div>

              <tfoot id='yVNrf'></tfoot>

                1. 本文介绍了MySQL删除左连接上的重复列,3个表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有三个表,每个表都有一个外键.当我执行连接时,我得到重复的列.

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

                  给定

                  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 语句语法是什么?

                  My objective is to get one row of all the columns from the join without duplicate columns. So what is the SQL statement syntax that I should use?

                  推荐答案

                  默认情况下,如果您使用 *,MySQL 将返回所有表的所有列.您需要在查询中明确输入列名,以按照您想要的方式检索它们.使用查询如下:

                  By default MySQL will return all columns for all tables if you use *. You will need to explicitly enter column names in your query to retrieve them the way you want. Use the query as follows:

                  SELECT A.HEAD_name, A.Family_Size, A.Gender, A.ID_Number, A.DOB,
                      B.Supervisor_ID, B.Supervisor_Name, B.Supervisor_Number,
                      C.Center_ID, C.Location
                  FROM Family A
                  JOIN SUPERVISOR B on ( A.Supervisor_ID = B.Supervisor_ID)
                  JOIN CENTER C on (B.Center_ID = C.Center_ID);
                  

                  这篇关于MySQL删除左连接上的重复列,3个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:MYSQL Left Join 如何选择 NULL 值? 下一篇:我们如何区分 LEFT OUTER JOIN 与 Left Join

                  相关文章

                    • <bdo id='XcmNh'></bdo><ul id='XcmNh'></ul>

                      <tfoot id='XcmNh'></tfoot>

                    1. <small id='XcmNh'></small><noframes id='XcmNh'>

                      <i id='XcmNh'><tr id='XcmNh'><dt id='XcmNh'><q id='XcmNh'><span id='XcmNh'><b id='XcmNh'><form id='XcmNh'><ins id='XcmNh'></ins><ul id='XcmNh'></ul><sub id='XcmNh'></sub></form><legend id='XcmNh'></legend><bdo id='XcmNh'><pre id='XcmNh'><center id='XcmNh'></center></pre></bdo></b><th id='XcmNh'></th></span></q></dt></tr></i><div id='XcmNh'><tfoot id='XcmNh'></tfoot><dl id='XcmNh'><fieldset id='XcmNh'></fieldset></dl></div>

                    2. <legend id='XcmNh'><style id='XcmNh'><dir id='XcmNh'><q id='XcmNh'></q></dir></style></legend>