Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Joins

Author  Topic 

cwtriguns2002
Constraint Violating Yak Guru

272 Posts

Posted - 2007-02-21 : 01:11:21
Hello everyone. What is meant by left join, right join, and cross join, etc...? Sorry for the question. Im using SQL 2005 for just 6 months, and only the INNER JOIN i know.

Thanks,
Ron

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-02-21 : 01:13:58
[url]http://www.microsoft.com/technet/technetmag/issues/2005/05/HowITWorksSQLJoins/?related=/technet/technetmag/issues/2005/05/HowITWorksSQLJoins[/url]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

cwtriguns2002
Constraint Violating Yak Guru

272 Posts

Posted - 2007-02-21 : 01:51:53
Ok Thanks Harsh. I have read the page, but I can't totally absorb how the cross join really works.
And other thing is, why is it a need to use cross join?

quote:

Cross Join - A cross join returns not the sum but the product of two tables. Each row in the left-hand table is matched up with each row in the right-hand table. It's the set of all possible row combinations, without any filtering, as shown here:

SELECT au_fname, au_lname, pub_name
FROM authors CROSS JOIN publishers
ORDER BY au_lname DESC

The resultset contains 184 rows (authors has 23 rows, and publishers has 8; therefore, 23 × 8 = 184). The first 11 rows look like


au_fname au_lname pub_name
Akiko Yokomoto New Moon Books
Akiko Yokomoto Binnet & Hardley
Akiko Yokomoto Algodata Infosystems
Akiko Yokomoto Five Lakes Publishing
Akiko Yokomoto Ramona Publishers
Akiko Yokomoto GGG&G
Akiko Yokomoto Scootney Books
Akiko Yokomoto Lucerne Publishing
Johnson White New Moon Books
Johnson White Binnet & Hardley
Johnson White Algodata Infosystems




In the example above, i can't get the idea you need to use cross join, in fact you are just assigning the author to all publisher...

Thanks,
Ron
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-02-21 : 02:05:18
Check this to understand the power of cross-join:

http://weblogs.sqlteam.com/jeffs/archive/2005/09/12/7755.aspx

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page
   

- Advertisement -