Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2003
    Posts
    2

    Red face Unanswered: how write selection

    hi
    i have two table:
    Table1
    S1 S2 S3
    1 2 1
    2 1 3
    3 3 2

    Table2
    id Text
    1 One
    2 Two
    3 Three

    How must i i write query to get such result:

    One Two One
    Two One Three
    Three Three Two

    Thank you
    p.s. sorry for my english

  2. #2
    Join Date
    Sep 2003
    Location
    London
    Posts
    56
    This look mightily like a homework assignment to me.

    Here's an article on using SQL joins that will help you out.

    http://www.devshed.com/Server_Side/M...oin/page1.html

    Matt.

  3. #3
    Join Date
    Dec 2003
    Posts
    2
    ghm...
    With joins?! I don't know how
    ok maybe in MySQL there are posible to merge two Query
    for example
    SELECT text as t1 FROM Table1, Table2 where id = s1
    and
    SELECT text as t2 FROM Table1, Table2 where id = s2

    and get one result with two colums T1 and T2
    ?????

    Thanks

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    select T2_1.text as T1text
         , T2_2.text as T2text
         , T2_3.text as T3text     
      from Table1
    inner
      join Table2 as T2_1
        on Table1.S1 = T2_1.id   
    inner
      join Table2 as T2_2
        on Table1.S2 = T2_21.id   
    inner
      join Table2 as T2_3
        on Table1.S3 = T2_3.id
    rudy
    http://r937.com/

  5. #5
    Join Date
    Nov 2003
    Location
    Philadelphia
    Posts
    9

    Re: how write selection

    Originally posted by Sliekas_satana
    hi
    i have two table:
    Table1
    S1 S2 S3
    1 2 1
    2 1 3
    3 3 2

    Table2
    id Text
    1 One
    2 Two
    3 Three

    How must i i write query to get such result:

    One Two One
    Two One Three
    Three Three Two

    Thank you
    p.s. sorry for my english
    SELECT Table2.text, Table2_1.text, Table2_2.text
    FROM Table2 AS Table2_2 INNER JOIN (Table2 AS Table2_1 INNER JOIN (Table2 INNER JOIN Table1 ON Table2.id = Table1.S1) ON Table2_1.id = Table1.S2) ON Table2_2.id = Table1.S3;

Posting Permissions

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