Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2011
    Posts
    1

    Unanswered: UNION SELECT query not handling concatenated fields

    I have 6 queries with the same 13 fields. 10 fields from each are being pulled into a UNION SELECT query. 1 of the fields being pulled is an email address field. This field is coded in the 6 queries as: Email: [Account] & "@xxxx.org"
    The Account field is pulled from an Outlook Global Access List table I linked to from my Outlook.
    The Email field appears fine in the 6 individual queries, but when I pull them all together in a UNION SELECT query some of the email addresses appear as @xxxx.org.
    Through testing, it appears that every other SELECT will not pull the email addresses correctly. For example:

    SELECT email
    FROM Table1

    UNION SELECT email
    FROM Table2

    UNION SELECT email
    FROM Table3

    UNION SELECT email
    FROM Table4

    UNION SELECT email
    FROM Table5

    UNION SELECT email
    FROM Table6;


    In the first example, the email addresses from Table1, Table3, and Table5 will display correctly while the email addresses from Table2, Table 4, and Table6 will only pull @xxxx.org

    However, if I switch the order around to this:

    SELECT email
    FROM Table2

    UNION SELECT email
    FROM Table3

    UNION SELECT email
    FROM Table4

    UNION SELECT email
    FROM Table5

    UNION SELECT email
    FROM Table6

    UNION SELECT email
    FROM Table1;

    Now the email addresses from Table2, Table4, and Table6 will display correctly while the email addresses from Table3, Table5, and Table1 will only pull @xxxx.org.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    can't help you unless you show the real queries
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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