I need help with a SQL query. My problem is better explained with some examples.
Say I have my data like this pulling from two tables.
Doc # | Item #
123 EDS100
123 DDS200
123 DDS500
124 LLS220
124 LDS254
125 FGD450
125 LDS552
125 DDS200
125 EDD200
I want to return all rows when 1 item number meets the criteria.
Say in this case I want all the rows of the order when one row is equal to DDS200 would give this result:
Doc # | Item #
123 EDS100
123 DDS200 -- match
123 DDS500
125 FGD450
125 LDS552
125 DDS200 -- match
125 EDD200
I'm sure this is trivial, I have tried the following:
SELECT doc#, item#
FROM order T0 INNER JOIN items T1 ON T0.doc = T1.doc
WHERE T1.item# like 'DDS200';
this only returns the rows that meet the criteria, not all the rows of the order as shown above.
Thanks for your help