Solved

SQL Query - Join or Subquery

Posted on 2008-06-20
1
232 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
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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…

776 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