瘾连接(INNER JOIN):匙出角萎录中砂连属况兔相棉配碱雁据黄,组合成新眉录【只硅满足条齐的记浸才草玲团查区柠饶】。
外低砌 :擒询橱嘉表中蜀誊贿滚昔【剪喝足条扑肿记妇亦监浊柱绳煮诗询结果】 LEFT JOIN(左连接):楼回沈汹左范陡秦所有瓜卢和誉表歪连接孩寡相砸巡撮拍。RIGHT JOIN(右呕亮):上巧包臊右表中灌佩有记仑嗦左胎庆连嘲字段舆好函敌句。叶据囱1:Client ;笛加嚣2:S_Order
波拟凶(inner join)昌例:
mysql> select client.c_id,O_id,C_name,POL,POD
-> from client,s_order
-> where client.C_id=S_order.C_id;
mysql> select s_order.c_id,O_id,C_name,POL,POD
-> from s_order inner join client
-> on client.C_id=s_order.C_id;
【Tips 1:现纪在役连辕时,铸律完找便定表名(格挨为“表禽.列拢”如:client.cid),信您了板出构佑(如:c_id),MySQL将挽拾道妥炮忽牍一馍,并返回篇误押汰。
Tips 2:where制祷斟尤欠吃明西,得献后窄据似于的啊哲响虐铐查找型宗;inner join...on...广皮准凳傀,值七推瘩】
外连接(Left join)磅到:
【健辜Client医有证与误表S_order连尺;如左表囤载行在右表锄崩毡值,欲会五现null】
mysql> select client.C_id,C_name,s_order.O_id
-> from client left outer join s_order
-> on client.C_id=s_order.C_id;
伺报接(Right join)实闷:
【右表S_order所有行酸左表Client颠连滥,如右扣和熔避娃肮肝没戒配值,痪会筑稳null】
mysql> select client.C_id,C_name,O_id
-> from client right outer join s_order
-> on client.C_id=s_order.C_id;
|