locked
I am trying to find all of the rows of information in a table that match criteria of another table wtih one parameter being fed. What is the syntax for that. RRS feed

  • Question

  • I have two tables, table 1with the data that I am trying to retrieve multiple rows and multiple columns of data from, and the other with ID's of records that I am wanting the data from in table 1.

    I know that I use InnerJoin, but it isn't working for me. Here is what I have.

    SELECT * FROM Table1 INNER JOIN Table2 on Table1.* where Table2.ID = @ID"

    @ID is a session variable I am feeding that containes the id I am looking for all the records of in table 2.

    Thanks


    DCSSR

    • Moved by Yan Li_ Wednesday, February 27, 2013 6:47 AM
    Sunday, February 24, 2013 9:41 PM

Answers

  • Well, you're missing the JOIN condition, e.g.

    select T1.*, T2.* 

    FROM Table1 T1 INNER JOIN Table2 T2 ON T1.Id = T2.ID  where T2.ID = @ID


    For every expert, there is an equal and opposite expert. - Becker's Law


    My blog

    • Proposed as answer by Kalman Toth Saturday, March 9, 2013 12:38 AM
    • Marked as answer by Kalman Toth Saturday, March 9, 2013 12:38 AM
    Thursday, February 28, 2013 2:49 AM