How can I get the correct po values according to the corresponding relevant no.
There is no correlation between the positions in the in clause.
This will probably give you the result you want.
select * from table1 where pono = '1' and dueno = '001' or pono = '2' and dueno = '001'
Alternatively, you can have a table / temp table / table variable with pairs of values to check for the use of exists or if you are in SQL Server 2008, you can do something like this.
select * from table1 as T1 where exists ( select * from (values('1','001'), ('2','001')) as T(pono, dueno) where T1.pono = T.pono and T1.dueno = T.dueno )
If you are using PostgreSQL, you can use this instead:
select * from table1 where (pono, dueno) in (('1', '001'), ('2', '001'))
source share