Database Articles

  Home arrow Database Articles arrow Writing UNION statements in MySQL 3.x
DATABASE ARTICLES

Writing UNION statements in MySQL 3.x
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 2
    2002-12-05

    Table of Contents:
  • Writing UNION statements in MySQL 3.x
  • Overview
  • The Details
  • Conclusion

  •  
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement

    Writing UNION statements in MySQL 3.x


    (Page 1 of 4 )

    For those of us who use MySQL, I think we can all share in our annoyance at the lack of the UNION command. We've been told that it will be implemented in the version 4.0 release, but we've been waiting a long time, and I doubt this will be resolved anytime soon. So, I guess that means we have to find our own way around the UNION statement.

    By : Michael Bailey

    For those of us who use MySQL, I think we can all share in our annoyance at the lack of the UNION command. We've been told that it will be implemented in the version 4.0 release, but we've been waiting a long time, and I doubt this will be resolved anytime soon. So, I guess that means we have to find our own way around the UNION statement.

    For those of you who do not know, the UNION statement allows a query to combine more than one SELECT statement into one all-powerful result set. This is useful when you have two tables with similar fields which you wish to combine into one SELECT. An example of this would be payments and charges in an accounting database. Each would be in a separate table, but each has similar fields (ex. amount, date, description, account, etc...).

    Without the UNION, you have to make two queries and combine them on the client side. This can be laborious in many situations, especially those which require sorting. As a rule of thumb, it's always best to let SQL do as much of the processing as possible. It saves in transfer time and processor time.

    So, how can one use a UNION statement without "using" a UNION statement?

    More Database Articles Articles
    More By Codewalkers

    blog comments powered by Disqus

    DATABASE ARTICLES ARTICLES

    - Completing a Book Inventory Management System
    - Uploading Images for a Book Inventory Manage...
    - Finishing the Add Book Story for a Book Inve...
    - Integration Testing for a Book Inventory Man...
    - User Stories for a Book Inventory Management...
    - Unit Testing a Book Inventory Management Sys...
    - Testing a Book Inventory Management System
    - Implementing Models for a Book Inventory Man...
    - Book Inventory Application: Publishers and B...
    - Handling Publishers in a Book Inventory Mana...
    - Publisher Administration for Book Inventory ...
    - Book Inventory Management
    - Using the SQL Reference Manual
    - Using Oracle SQL Developer with SQL Statemen...
    - Fixing Errors with Oracle SQL Developer


    © 2003-2012 by Developer Shed. All rights reserved. DS Cluster 2 - Follow our Sitemap