I am trying to narrow down the results returned from a JOIN so that the shared value equal a specific value.
The basic query which returns the entire contents of the tables.
SELECT t1.c2, t2.c3 FROM t1
INNER JOIN t2 ON t1.c3 = t2.c4
I know I can add t1.c3 to the select list and loop through the returned data to find the t1.c3 with a specific value. But I am wondering if there is an automagical way to get only the joined data when the value of t1.c3 and t2.c4 = ‘xyz’.
2
Answers
Just put your criteria into the join condition:
It seems you are simply asking for a condition in a
WHERE
clause:As it is the same column on which you want to filter and join both tables, you can also consider this a cross join on the filtered sets: