-
joins in Sql server
I have a very silly question.Does anyone know What is result of Inner Join ( left Join, Outer Join)
I tried to search but did not find any results for this.I would really appreciate if someone helps me out.
Thanks,
Siri
-
Did you check BOL (= Books onLine = the SQL Server online documentation) . this is usually the first place to search in.
Anyway: Assume two tables:
Categories (catid, catname)
1, science
2, novel
3, newspaper
Lectures (lectureid, title, catid)
1, 'E=mc2', 1
2, 'Database Theory', 1
3, 'Tommyknockers', 2
Inner Join: joins two tables togeher and displays all combinations out of both tables where the joined fields are identical.
Taking the sample tables this means: If you inner join Categories and lectures on catid you get a list of all books with their corresponding catname
Left Join or better: Left outer Join
If you create a left outer join from categories to lectures you will get all categories with the books associated to them plus the non-used category newspaper
-
Inner Joins are simple enough as it only returns the data where the join criteria match on both sides. When I was first learning SQL, it helped me to visualize the outer joins in my head.
I would picture two tables (like an open table in Enterprise Manager) and visualize that a left join would return all records on the left side and matching records on the right side. A right join is the opposite.
-
is a cross join the same as a union ?
-
-
A Cross Join joins each row from the first (top) input with each row from the second (bottom) input.
A union isn't a join at all. A union combines results from two or more queries into one result set so that the records are returned as separate records, not combined.
-
Thank you for the help..
Siri
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|