Solved

SQL Query - Join or Subquery

Posted on 2008-06-20
1
235 Views
Last Modified: 2010-03-20
 Two tables, one called tblOffice the other called tblFactory.

Both tables have the following fields.  FirstName, LastName, Birthday

I need to combine (join) both tables where the Birthday = today's date.

      DIM vDate       
      vDate       = Date()  

      vSQL = "" 
      vSQL = vSQL & " SELECT o.FirstName, o.LastName, 0.Birthday, f.FirstName,  f.LastName, f.Birthday  "
      vSQL = vSQL & " FROM tblOffice o "
      vSQL = vSQL & " CROSS JOIN tblFactory f "      
      vSQL = vSQL & " WHERE o.Birthday  = '" & vDate & "' OR  f.Birthday  = '" & vDate & "' "

Cross join does not appear to be producing the correct results.
0
Comment
Question by:pgooseman
[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 11

Accepted Solution

by:
asafadis earned 500 total points
ID: 21831963
Try something along the lines of:
SELECT o.FirstName, o.LastName, o.Birthday
FROM   tblOffice o
WHERE  o.Birthday = vDate
UNION
SELECT f.FirstName, f.LastName, f.Birthday
FROM   tblFactory f
WHERE  f.Birthday = vDate

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

729 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