日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) >

mysql左键关联_MySQL的:左键删除重复列加入,3个表

發(fā)布時(shí)間:2023/12/4 62 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql左键关联_MySQL的:左键删除重复列加入,3个表 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

我有一個(gè)表,使用3個(gè)外鍵到其他表.當(dāng)我執(zhí)行左連接時(shí),我會(huì)收到重復(fù)的列.

MySQL表示,USING語(yǔ)法將減少重復(fù)的列,但沒(méi)有多個(gè)鍵的示例.

鑒于:

mysql> describe recipes;

+------------------+------------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+------------------+------------------+------+-----+---------+-------+

| ID_Recipe | int(11) | NO | PRI | NULL | |

| Recipe_Title | char(64) | NO | | NULL | |

| Difficulty | int(10) unsigned | NO | | NULL | |

| Elegance | int(10) unsigned | NO | | NULL | |

| Quality | int(10) unsigned | NO | | NULL | |

| Kitchen_Hours | int(10) unsigned | NO | | NULL | |

| Kitchen_Minutes | int(10) unsigned | NO | | NULL | |

| Total_Hours | int(10) unsigned | NO | | NULL | |

| Total_Minutes | int(10) unsigned | NO | | NULL | |

| Serving_Quantity | int(10) unsigned | NO | | NULL | |

| Description | varchar(128) | NO | | NULL | |

| ID_Prep_Text | int(11) | YES | | NULL | |

| ID_Picture | int(11) | YES | | NULL | |

| Category | int(10) unsigned | NO | | NULL | |

| ID_Reference | int(11) | YES | | NULL | |

+------------------+------------------+------+-----+---------+-------+

15 rows in set (0.06 sec)

mysql> describe recipe_prep_texts;

+------------------+---------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+------------------+---------------+------+-----+---------+-------+

| ID_Prep_Text | int(11) | NO | PRI | NULL | |

| Preparation_Text | varchar(2048) | NO | | NULL | |

+------------------+---------------+------+-----+---------+-------+

2 rows in set (0.02 sec)

mysql> describe recipe_prep_texts;

+------------------+---------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+------------------+---------------+------+-----+---------+-------+

| ID_Prep_Text | int(11) | NO | PRI | NULL | |

| Preparation_Text | varchar(2048) | NO | | NULL | |

+------------------+---------------+------+-----+---------+-------+

2 rows in set (0.02 sec)

mysql> describe mp_references;

+--------------+---------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+--------------+---------+------+-----+---------+-------+

| ID_Reference | int(11) | NO | PRI | NULL | |

| ID_Title | int(11) | YES | | NULL | |

| ID_Category | int(11) | YES | | NULL | |

+--------------+---------+------+-----+---------+-------+

3 rows in set (0.00 sec)

我的查詢(xún)語(yǔ)句:

SELECT *

FROM Recipes

LEFT JOIN (Recipe_Prep_Texts, Recipe_Pictures, mp_References)

ON (

Recipe_Prep_Texts.ID_Prep_Text = Recipes.ID_Prep_Text AND

Recipe_Pictures.ID_Picture = Recipes.ID_Picture AND

mp_References.ID_Reference = Recipes.ID_Reference

);

我的目標(biāo)是從連接中獲取一行不含重復(fù)列的所有列.我使用MySQL C連接器發(fā)送SQL語(yǔ)句并檢索結(jié)果集.我相信C連接器有重復(fù)列名的問(wèn)題.

那么我應(yīng)該使用什么是SQL語(yǔ)句語(yǔ)法?

總結(jié)

以上是生活随笔為你收集整理的mysql左键关联_MySQL的:左键删除重复列加入,3个表的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。