Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2004
    Posts
    40

    Unanswered: union code help.

    i have 7 table, each have main 7 field(different name)

    how u do the union all the table in one ?

    i cant simple write like that,

    select [field1],[field2],[field3],[field4],[field5],[field6],[field7]
    from [table1]

    union select [field1],[field2],[field3],[field4],[field5],[field6],[field7]
    from [table2]

    union select [field1],[field2],[field3],[field4],[field5],[field6],[field7]
    from [table3]

    lol.... but.. any help is greatly appreciated.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by xeroleacy
    i cant simple write like that, ...
    yes, you can
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Oct 2003
    Location
    US
    Posts
    343
    Yes you can but make sure that the data type remains the same for all the 7 unions.


    Quote Originally Posted by xeroleacy
    i have 7 table, each have main 7 field(different name)

    how u do the union all the table in one ?

    i cant simple write like that,

    select [field1],[field2],[field3],[field4],[field5],[field6],[field7]
    from [table1]

    union select [field1],[field2],[field3],[field4],[field5],[field6],[field7]
    from [table2]

    union select [field1],[field2],[field3],[field4],[field5],[field6],[field7]
    from [table3]

    lol.... but.. any help is greatly appreciated.

  4. #4
    Join Date
    Jun 2004
    Location
    Seattle, WA
    Posts
    601
    All the stuff I have seen they put () around sub-selects..try that
    Ryan
    My Blog

Posting Permissions

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