SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Get my greedy down dotJoon's Avatar
    Join Date
    Apr 2003
    Location
    daejeon, South Korea
    Posts
    2,207
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    producing as many as row count in the table "group1" with UNION results

    Code:
    data in the table "words"
    
    word1    word2
    gold     jewelry
    jewelry  diamond
    I have the table like the above.
    The code below yields the result below.
    Code:
    code
    
    SELECT word2 as word
    FROM words
    WHERE
    word1='jewelry'
    
    UNION ALL
    
    SELECT word1 as word
    FROM words
    WHERE
    word2='jewelry'
    
    result
    
    diamond
    gold
    So far, so good.

    Here goes what I want.
    I have another table named myGroup1 like the below.
    Code:
    data in the table "myGroup1"
    
    group1
    group1-1
    group1-2
    I like to yield my target result below joining the table "words" and "group1."
    Code:
    target result
    
    diamond group1-1
    diamond group1-2
    gold group1-1
    gold group1-2

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,398
    Mentioned
    147 Post(s)
    Tagged
    4 Thread(s)
    Join the tables.


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
  •