Sql join 語法
SQL Join語法
Join有兩種屬性:
INNER
OUTER
1.INNER
只顯示匹配的行.
2.OUTER
不論是否匹配,都顯示行.
LEFT, RIGHT, FULL 都帶有OUTER屬性
Join共有六種:
Inner Join
Natural Join
Left Outer Join
Right Outer Join
Full Outer Join
Cross Join
1.Inner Join
Inner Join其實等同於多個Where條件式的連結,
像
FROM a, b WHERE a.id = b.id AND b.val > 5
FROM a INNER JOIN b ON (a.id = b.id) WHERE b.val > 5
是一樣的
2.Natural Join
Natural Join只是自動的匹配兩個表之間相同的欄位,
像
FROM a, b WHERE a.id = b.id AND b.val > 5
FROM a NATURAL JOIN b WHERE b.val > 5
是一樣的.
可用在任何一種Inner 或 Outer Join.
Natural 與 USING 也是很相像的,只是Natural
只會讓兩個表的相同欄位出現一次.
3.Left Outer Join
4.Right Outer Join
其實這兩個幾乎是一樣的,只是方向性的不同.
以Left Outer Join來說,左邊顯示所有左表的值,而右邊顯示右表匹配的值.
如果沒有匹配的右表表,則放空值.
Right Outer Join則左右方向相反.
5.Full Outer Join
左右表都顯示,匹配的則顯示,沒有匹配的放空值.
好比把 Left Outer Join 和 Right Outer Join作聯集.
6.Cross Join
交叉連結,會得到兩個表的所有乘積組合.
迴響
Sql join 語法 | 豬窩
Cbd oil that works 2020
It's not my first time to go to see this web page, i am visiting this website dailly
and obtain fastidious information from here all
the time. best cbd oil for pain http://bit.ly/3drY6lE cbd oil that works 2020 http://bit.ly/3drY6lE
Sql join 語法 | 豬窩
If you want to increase your experience only keep visiting this website
and be updated with the most recent gossip posted here.
Sql join 語法 | 豬窩
This article is genuinely a nice one it assists new net viewers, who are wishing for blogging.
Sql join 語法 | 豬窩
What's Happening i am new to this, I stumbled upon this I have discovered It positively useful and it
has aided me out loads. I hope to give a contribution & aid other users like
its aided me. Great job.
Sql join 語法 | 豬窩
My family every time say that I am wasting my time here
at net, but I know I am getting know-how daily by reading such good articles or reviews.