Results 1 to 3 of 3

Thread: Need help getting information from 2 tables at once

  1. #1
    M Eason Guest

    Need help getting information from 2 tables at once


    I'm trying to access data from one table by matching ids pulled from another table. I can't quite get the syntax though if anybody could help I would appericate it.

    Here is where I'm at

    select * from table1 where variable 1 = (select distinct(variable 2) from table 2 where variable 3 = variable 4)

  2. #2
    Paul Asaro Guest

    Need help getting information from 2 tables at once (reply)

    Not quite sure what you are tying to accomplish but this is valid syntax. If the join column is t1.variable1 to t2.variable2 and the where condition is t2.variable2 = t2.variable4 than this is correct.

    Thanks,

    Paulie

    SELECT t1.*
    FROM table1 as t1
    JOIN
    table2 as t2 ON t1.variable1 = t2.variable2
    WHERE t2.variable2 = t2.variable4


  3. #3
    Juergen Leis Guest

    Need help getting information from 2 tables at once (reply)

    Another way (eliminating duplicate rows) could be

    select * from table1 where variable1
    IN
    (select distinct(variable2) from table2 where variable3 = variable4)



    ------------
    Paul Asaro at 1/4/2002 10:41:01 AM

    Not quite sure what you are tying to accomplish but this is valid syntax. If the join column is t1.variable1 to t2.variable2 and the where condition is t2.variable2 = t2.variable4 than this is correct.

    Thanks,

    Paulie

    SELECT t1.*
    FROM table1 as t1
    JOIN
    table2 as t2 ON t1.variable1 = t2.variable2
    WHERE t2.variable2 = t2.variable4


Posting Permissions

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