Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2008
    Posts
    16

    Unanswered: SQL query help needed

    Hi,
    I have 2 tables table 1 and Table 2

    Table 1 looks like this

    A

    1
    7
    8

    Table 2 looks like this

    A B C

    1 2 10
    1 3 20
    1 4 30
    1 5 40

    Like this i have so many combination of recs in table 2 . I need to write a query to select only those recs for which t1.A=t2.A and and t2.C should be the set of 10,20& 30 alone.. In this way i need to select.

    Plz help me.

    Thanks.
    Last edited by vijayarajvp; 05-08-09 at 06:08.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    SELECT t1.A
         , t2.B
         , t2.C
      FROM Table1 AS t1
    INNER
      JOIN Table2 AS t2
        ON t2.A = t1.A
       AND t2.C IN ( 10, 20, 30 )
    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
  •