Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS Access / SQL Query Help

Status
Not open for further replies.

RockManFree

Technical User
Dec 24, 2011
3
I need a SQL query to return ALL fields of Table1 and any fields from Table2 where "Slot" is equal.

Table1 has one field named "Slot" and it has 10 rows of sample data (The data = 01,02,...,10)

Table2 has three fields named "Slot" "Contents" and "Status" with the following sample data (it only has three records):
Slot=1 Contents=Red Status=New
Slot=6 Contents=Blue Status=New
Slot=8 Contents=Green Status=Old

The final outcome should look like this: (I need the SQL code that would produce this)

SLOT CONTENTS STATUS
1 Red New
2
3
4
5
6 Blue New
7
8 Green Old
9
10

Please note that all slots 1-10 are reported from Table1 even tho there is no records in Table2 for some of the Slots.

Thank you!
 
classic left outer join :)
Code:
SELECT slots.slot
     , data.contents
     , data.status
  FROM table1 AS slots
LEFT OUTER
  JOIN table2 AS data
    ON data.slot = slots.slot

r937.com | rudy.ca
Buy my new book Simply SQL from Amazon
 
Thanks but this did not work in MS Access 2002. I'm a newbee so have mercy on me, but in my example I did not have a table called "slots" nor a table called "data". Just a table called "table1" and a table called "table2". Any further clarification would be highly appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top