Database Articles
  Home arrow Database Articles arrow Writing UNION statements in MySQL 3.x
IBM developerWorks
Try It Free
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Forums Sitemap 
Dedicated Servers  
Download TestComplete 
IBM® developerWorks
Weekly Newsletter 
 
Developer Updates  
Free Website Content 
IBM developerWorks
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DATABASE ARTICLES

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

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

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
    Try It Free
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    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


     

    DATABASE ARTICLES ARTICLES

    - More on Query Optimization for Oracle Databa...
    - Query Optimization in Oracle
    - Clusters and Other Data Structures for Oracle
    - Using Indexes with an Oracle Database
    - The Basics of Data Structures in Oracle
    - Oracle Data Structures
    - Best Practices for PL/SQL Variables
    - What`s Code Without Variables?
    - Clauses, Sorting, and SQL Queries
    - The From Clause and SQL Queries
    - Query Primer
    - Full Text Searches and Strings
    - Searching with Strings
    - Pattern Matching with Strings
    - Working with Cases of Strings





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway