Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2004
    Posts
    41

    Answered: Query row of data to separate rows

    Hi, I would like to pull a table's row of data to 2 rows of data, such as:

    Table1
    ID NAME EMAIL
    --------------------------------
    1 Tom Sawyer tsawyer@g.com
    2 Huck Finn hfinn@gmail.com


    Query result:
    ----------------
    Tom Sawyer
    tsawyer@google.com
    Huck Finn
    hfinn@gmail.com


    Any help would be appreciated!

  2. Best Answer
    Posted by informer

    "Hi Reg


    I propose you this query

    PHP Code:
    SELECT col FROM
    SELECT "0" as flag ID ,NAME AS colEMAIL FROM tblContact
    UNION 
    SELECT 
    "1" as flag ,ID,   EMAIL as colNAME FROM tblContact)
    order by IDflag 
    "


  3. #2
    Join Date
    May 2016
    Posts
    89
    Provided Answers: 4
    Hi Reg


    I propose you this query

    PHP Code:
    SELECT col FROM
    SELECT "0" as flag ID ,NAME AS colEMAIL FROM tblContact
    UNION 
    SELECT 
    "1" as flag ,ID,   EMAIL as colNAME FROM tblContact)
    order by IDflag 

  4. #3
    Join Date
    Dec 2004
    Posts
    41
    Thank you @informer, this worked perfectly!

Posting Permissions

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