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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Left join table with filter

Status
Not open for further replies.

Aurillius

Programmer
Jun 3, 2004
60
CA
Hi,

I'm trying to create a left join between 2 tables and the right table has a filter. The problem that I'm having is that I'd like to still show all records on the left table and show a blank cell on the right table.
Here is a simplified version of what I have...

SELECT tableA.item
FROM tableA LEFT JOIN tableB ON tableA.item = tableB.item
WHERE (((tableB.date)=#8/31/2006#));

tableA and tableB have the same data in the item field but tableB has a date field with one date that is different.
Thanks,
Mark
 
Code:
SELECT tableA.item
  FROM tableA 
LEFT 
  JOIN tableB 
    ON tableB.item = tableA.item
   [b]AND[/b] tableB.date = #8/31/2006#

r937.com | rudy.ca
 
SELECT tableA.item
FROM tableA LEFT JOIN (
SELECT * FROM tableB WHERE tableB.date=#8/31/2006#
) AS B ON tableA.item = B.item

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thank you very much! The embedded select statement was the key.
Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top