0

Mysql で Employee データベースを使用しています。私のデータベースには次のテーブルが含まれています

    mysql> describe edept;     
+-------+-------------+------+-----+---------+-------+  
| Field | Type        | Null | Key | Default | Extra |  
+-------+-------------+------+-----+---------+-------+
| id    | int(11)     | NO   | PRI | NULL    |       |
| dept  | varchar(20) | NO   |     | NULL    |       |
+-------+-------------+------+-----+---------+-------+


mysql>describe esal;
+-------+---------+------+-----+---------+-------+
| Field | Type    | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| id    | int(11) | NO   | PRI | NULL    |       |
| basic | int(11) | NO   |     | NULL    |       |
| pf    | int(11) | NO   |     | NULL    |       |
+-------+---------+------+-----+---------+-------+

mysql> describe edesig;
+-------+-------------+------+-----+---------+-------+
| Field | Type        | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| id    | int(11)     | NO   | PRI | NULL    |       |
| desig | varchar(20) | NO   |     | NULL    |       |
+-------+-------------+------+-----+---------+-------+


mysql> select * from edetails inner join edept on edetails.dept=edept.id;
+----+--------+-----+------+-------+-------+----+----+------------------+
| id | name   | age | dept | desig | basic | pf | id | dept             |
+----+--------+-----+------+-------+-------+----+----+------------------+
|  1 | swetha |  21 |    3 |     2 |     2 |  2 |  3 | Business Process |
+----+--------+-----+------+-------+-------+----+----+------------------+


mysql> describe edetails;
+-------+-------------+------+-----+---------+-------+
| Field | Type        | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| id    | int(11)     | NO   | PRI | NULL    |       |
| name  | varchar(20) | NO   |     | NULL    |       |
| age   | int(11)     | NO   |     | NULL    |       |
| dept  | int(11)     | NO   | MUL | NULL    |       |
| desig | int(11)     | YES  | MUL | NULL    |       |
| basic | int(11)     | NO   | MUL | NULL    |       |
| pf    | int(11)     | NO   | MUL | NULL    |       |
+-------+-------------+------+-----+---------+-------+

テーブル edept.dept、edesig.desig、esal.basic、esal.pf からそれぞれ dept、desig、basic、pfの値を取得する必要があります。
他のテーブルから値を取得する必要があるすべてのフィールドに外部キーを使用しました。そして、サンプルの内部結合クエリを試しました。しかし、私は次のように出力を得ました:

 mysql> select * from edetails inner join edept on edetails.dept=edept.id;
    +----+--------+-----+------+-------+-------+----+----+------------------+
    | id | name   | age | dept | desig | basic | pf | id | dept             |
    +----+--------+-----+------+-------+-------+----+----+------------------+
    |  1 | swetha |  21 |    3 |     2 |     2 |  2 |  3 | Business Process |
    +----+--------+-----+------+-------+-------+----+----+------------------+

My edept table contains the following:


 mysql> select * from edept;
+----+------------------+
| id | dept             |
+----+------------------+
|  3 | Business Process |
+----+------------------+



How can i eliminate duplicate columns. i need the value "business process" in the dept field of the edept table
4

1 に答える 1