Sunday 15 September 2013

I'm looking for the logic behind combining multiple join operations in MySQL to select data from more than 2 tables -



I'm looking for the logic behind combining multiple join operations in MySQL to select data from more than 2 tables -

i'm trying wrap head around different bring together operations in mysql , found useful info on website when explained venn diagrams. i'm confused, however, on how combine select join statements when want select info 3 or more tables.

does have beginners reference logic behind this? or giving me crash course?

thank you

in way, joining 3 tables no more hard grasp joining 2 tables.

the bring together operator binary operator in same way add-on or multiplication binary operators. can "chain" them.

so can utilize add-on sum 3 or more terms:

2 + 4 + 3

you can utilize bring together join 3 or more tables:

select ... books bring together authors on books.author_id = authors.author_id bring together publishers on books.publisher_id = publishers.publisher_id

you can visualize means:

+---------+ +-------+ +------------+ | authors | | books | | publishers | +---------+ +-------+ +------------+ | |<-------| b |--- | | | | | | | | | | | | | --->| p | +---------+ +-------+ +------------+

the purpose match row books related rows in authors , publishers, respectively.

re questions:

it seems weird me statement occurs once

does seem weird when see arithmetic look following:

sqrt( 2 + 4 + 1 )

why sqrt appear once? because it's function beingness applied result of internal expression.

think of from clause way:

"i selecting columns from next set of joined tables. first bring together them, i'll select columns want."

does order of bring together statements impact outcome?

no, bring together operation commutative. is, 2+4 = 4+2 in addition, joins give same result in either direction. in fact, internally sql databases may take access table in either order according makes more efficient.

the exception left outer join or right outer join, not commutative. order matters.

mysql join

No comments:

Post a Comment