Skip to content
Advertisement

How can I check if the ID’s of a table match another ID’s of another table in SQL

So I have 4 parameters, one of them its given as an input parameter of a stored procedure (its like a code that represents an unique action), and I need to match these ID’s with another ID’s in another table, so I need to check in table 2 the ID’s “DeliverTypeID”, “ScheduleTypeID”, “CourseID” if they are all the same as table 1, if they really are then it should print me out the corresponding records.

I need to do this selection by a Stored Procedure.

Here’s my code so far:

Minimal Example :

Thank you very much in advance.

Advertisement

Answer

I think what you are looking for is the following. I don’t think you need the variables, just the correct logic in your single join (it seems unlikely you want to join Table2 on 3 times).

Note I recommend the use of table aliases for clarity.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement