Solved

Is it possible to streamline this query?

Posted on 2004-10-27
185 Views
Last Modified: 2013-12-24
Hi,

I have this awful query that I would like to streamline, and add a where clause.
Any ideas?

SELECT *
FROM
table1
Where (firstout Between #MonthStart# and #MonthEnd#)
UNION all

SELECT *
FROM
table2
Where (firstout Between #MonthStart# and #MonthEnd#)
UNION ALL

SELECT *
FROM
table3
Where (firstout Between #MonthStart# and #MonthEnd#)

order by pk
0
Question by:g118481
    5 Comments
     
    LVL 35

    Expert Comment

    by:mrichmon
    well in order to answer this question you will have to tell us what is included in the * in each table.... and how the tables are related.

    It would also help to know what kind of data you are pulling.
    0
     
    LVL 17

    Accepted Solution

    by:
    I'm not sure how you can streamline this query even more?
    You already have a where clause for each query in the union.. What more do you want?
    0
     
    LVL 1

    Author Comment

    by:g118481
    The tables are not really related, but they do have the same field names.  The data is simple calendar data.
    0
     
    LVL 35

    Assisted Solution

    by:mrichmon
    Then I don't think you can do any more if they are not related.

    You will be forced to have a union per table if there is no other relation between the tables.
    0
     
    LVL 17

    Expert Comment

    by:Tacobell777
    exactly..
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Suggested Solutions

    Title # Comments Views Activity
    nginx reverse proxy 6 66
    multi page pdf 4 57
    VPN Dedicated IP address question 7 35
    Webserver access problem 5 32
    Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
    If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
    Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    846 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

    10 Experts available now in Live!

    Get 1:1 Help Now