Multiple filter on same column
I have an situation here. I have two tables (Tab-1 & Tab-2)
I need to pull the records from Table1 whose Status = 'S' and ApplicationID in Table1 should match with the ApplicationID in Table2 Where Table2.Type <>'o' and Table2.Status<>'X' and Table2.Status IN ('A','I').
In Table2, for Status columns i have values like X, A, I, T, N.
I need only the applicationID where Status has only 'A' or/and 'I' from Table2
Can someone please help.
Hi Jomy Joy , this can be achieved using a subquery, such as in the following:
SELECT * FROM table1 WHERE application_id IN ( SELECT application_id FROM table2 WHERE type <> 'o' AND status IN ('A', 'I') ) AND status = 'S';
Take a look at Writing Subqueries in SQL to learn more about what this code is doing!