Ms7 Search
Google 搜尋 翻譯
calendar
« 九月 2024 »
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30            
近期文章
文章分類
網站連結
Syndicate

« | »

Sql join 語法

2009-02-23 @ 19:13 in PHP, JavaScript, Sql

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
交叉連結,會得到兩個表的所有乘積組合.

資料來源:http://www.wretch.cc/blog/sky4s/2250385

迴響

Sql join 語法 | 豬窩

Hi there friends, how is the whole thing, and what you want to say on the topic of this piece
of writing, in my view its really awesome designed for me.

作者 best web hosting sites @ 12:21, 2020-07-23

Sql join 語法 | 豬窩

Hi there! I know this is kinda off topic but I'd figured I'd ask.
Would you be interested in trading links or maybe guest authoring a blog post or vice-versa?
My website discusses a lot of the same subjects as yours and I think we could greatly benefit from each
other. If you are interested feel free to send me an email.
I look forward to hearing from you! Awesome blog by the
way!

作者 best web hosting company @ 04:11, 2020-07-27

Sql join 語法 | 豬窩

Hello would you mind stating which blog platform you're working with?
I'm going to start my own blog soon but I'm having a hard time making
a decision between BlogEngine/Wordpress/B2evolution and Drupal.
The reason I ask is because your layout seems different
then most blogs and I'm looking for something completely unique.

P.S Sorry for getting off-topic but I had to ask!

作者 airline tickets @ 07:51, 2020-07-28

Sql join 語法 | 豬窩

First of all I want to say awesome blog! I had a quick question that I'd like
to ask if you don't mind. I was interested to know
how you center yourself and clear your mind prior to writing.
I have had a difficult time clearing my mind in getting my
thoughts out there. I do take pleasure in writing but it
just seems like the first 10 to 15 minutes are generally wasted simply
just trying to figure out how to begin. Any recommendations or tips?
Appreciate it!

作者 book flight @ 15:15, 2020-07-29

Sql join 語法 | 豬窩

hello!,I like your writing so much! percentage we communicate
more about your article on AOL? I require an expert in this space to unravel my problem.
May be that is you! Looking forward to see you.

作者 hosting services @ 02:48, 2020-08-07
«上一篇   1 2
發表迴響
 authimage