?
Solved

Multiple outer joins in transact SQL

Posted on 1998-07-17
1
Medium Priority
?
326 Views
Last Modified: 2010-03-19
I have a multi-table database (aren't they all) which requires several outer join statements and we are piecing it together by the key columns.  Can someone give me an example of a SQL statement which incorporates multiple outer joins.
Maybe using the famous "Pubs" database MS uses.

Thanks Heaps, buckets, and chick peas.
0
Comment
Question by:oldmanbran
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 1

Accepted Solution

by:
Staplehead earned 20 total points
ID: 1091786
well, i don't have that DB on my machine here, but assume the following db:

employees: nbr, last_name, first_name
offices: nbr, bldg, room, emp_nbr
computers: nbr, manufacturer, model, tag, emp_nbr

to list employees, their offices, and what computer(s) they have:

SELECT employees.first_name, employees.last_name, offices.bldg, offices.room, computers.manufacturer, computers.model, computers.tag
FROM (employees OUTER JOIN offices ON employees.nbr=offices.emp_nbr) OUTER JOIN computers ON computers.emp_nbr=employees.nbr
ORDER BY employees.last_name, employees.first_name;

not a big example, but you get the idea; if you need more tables, you can just keep cascading them.  keep in mind that if, for example, the left side of a join is the result of another join and the right side is a new table, then one of your "ON" fields is from the original set of tables (on the left) and the other is from the new table..

Larry
0

Featured Post

Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question