MySQL syntax

Posted on 2012-09-06
Last Modified: 2012-09-06
I have two tables with identical structure. For a report, I want to select data from both, based on dates.

So I tried this: SELECT * FROM `resva` WHERE date > '2012-06-15', * from resv where date < '2012-07-30'

It fails.

What is the proper syntax?

Question by:Richard Korts
    LVL 5

    Expert Comment

    SELECT * FROM `resva` WHERE date > '2012-06-15'
    SELECT * FROM `resv` WHERE date > '2012-07-30'

    Author Comment

    by:Richard Korts
    To gbartley

    That works great. I didn't mention it but I want to order by one (or several) columns. I tried the following & it failed. How do I add "order by"?

    SELECT * FROM `resva` WHERE date > '2012-06-15' order by pickup
    SELECT * FROM `resv` WHERE date < '2012-07-17' order by pickup

    LVL 5

    Expert Comment

    Try brackets

    (SELECT * FROM `resva` WHERE date > '2012-06-15' order by pickup)
    (SELECT * FROM `resv` WHERE date < '2012-07-17' order by pickup)
    LVL 5

    Accepted Solution

    Better to order the final result

    (SELECT * FROM `resva` WHERE date > '2012-06-15')
    (SELECT * FROM `resv` WHERE date < '2012-07-17' )
    ORDER BY pickup

    Author Closing Comment

    by:Richard Korts
    Excellent and works fast too,


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Suggested Solutions

    Title # Comments Views Activity
    MySQL Trigger 8 25
    MySQL: Grouping results with JOIN 8 32
    query not pulling in ID column correctly on query 4 31
    MySQL 11 46
    As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
    I have been using r1soft Continuous Data Protection ( for many years now with the mySQL Addon and wanted to share a trick I have used several times. For those of us that don't have the luxury of using all transact…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    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…

    761 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

    7 Experts available now in Live!

    Get 1:1 Help Now