I have a MainInfo table and 3 different Log tables (PleadingsLog, LitigationLog and DiscoveryLog) that are linked to the MainInfo table by an IDnumber. Each of the log tables contains a date field and a notes field.

I am trying to find a way to query all records from the MainInfo table that show a date within the next 30 days in ANY of the 3 associated log tables. I have been able to query the records through each of the Logs individually, but not all together.

I tried adding all 3 log tables to the query, and I got the following results: (1) when I added the date criteria to the date field from LitigationLog, I got multiple returns for the record due to other dates entered in the other logs, or (2) if I enter the same date criteria in each of the date fields (from each of the 3 Log tables), it returns no records because there are no records that have a future date in ALL of the related logs tables. Any help is sincerely appreciated.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States.
Privacy

Processing your response...

Discuss This Question: 3 &nbspReplies

There was an error processing your information. Please try again later.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States.
Privacy

2 Carlosdl
> Note than applying the criteria to each individual subquery could be more efficient.
I agree in the general case, but SQL Server optimizer gives identical execution plans (with predicate inside). :-)

Thank you for your responses. I have never used a Union Query before. I created the Union Query using SQL and did use the WHERE condition for the dates for each subquery. It worked beautifully. Thank you again!

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States.
Privacy

Processing your reply...

Ask a Question

Free Guide: Managing storage for virtual environments

Complete a brief survey to get a complimentary 70-page whitepaper featuring the best methods and solutions for your virtual environment, as well as hypervisor-specific management advice from TechTarget experts. Don’t miss out on this exclusive content!

Share this item with your network:

To follow this tag...

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States.
Privacy