SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: mysql JOIN help

  1. #1
    SitePoint Addict jamesbond's Avatar
    Join Date
    Feb 2001
    Location
    The Netherlands
    Posts
    256
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    mysql JOIN help

    If I would have 3 tables with the same structure:

    table1(code,name,description)
    table2(code,name,description)
    table3(code,name,description)

    How can I construct a query which will retrieve all the records from the 3 tables and order them by code

    Doing 3 seperate queries doesn't give me the desired result because I would end up with duplicates and the order would not be correct.

    I've been thinking about creating a temporary table and inserting all the records in it and then doing a query on the temporary table.

    Isn't there an easier way to do it?

  2. #2
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah - what you want is a UNION query which MySQL does not support. The manual actually suggests your proposal of creating a temporary table and querying that. If you do a search for UNION you will probably find some threads from the past where this has been discussed - I remember there being some interesting work-arounds discussed in the past - cant remember the specifics though


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •