Results 1 to 2 of 2

Thread: UNION -- identifying the table used.

  1. #1
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    1,696
    Thanks
    82
    Thanked 90 Times in 88 Posts

    Default UNION -- identifying the table used.

    Code:
    (select ID, title from table1 order by ID asc limit 10)
    UNION
    (select ID, title from table2 order by ID asc limit 10)
    Using php or MySQL how can you match the results with the table it was retrieved from?
    Last edited by james438; 05-07-2010 at 03:33 AM.
    To choose the lesser of two evils is still to choose evil. My personal site

  2. #2
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    1,696
    Thanks
    82
    Thanked 90 Times in 88 Posts

    Default

    Code:
    (select ID, title,  table1 AS col1 from table1 order by ID asc limit 10)
    UNION
    (select ID, title, table2 AS col1 from table2 order by ID asc limit 10)
    solved the problem where col1 is just a dummy column name.
    To choose the lesser of two evils is still to choose evil. My personal site

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
  •