Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Multiple outer joins in transact SQL

Posted on 1998-07-17
1
Medium Priority
?
327 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

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
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.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

636 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