Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SQL Query - Join or Subquery

Posted on 2008-06-20
1
Medium Priority
?
238 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 2000 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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

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…
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
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.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

597 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