Solved

SQL Query - Join or Subquery

Posted on 2008-06-20
1
228 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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now