Multiple column with in keyword
-
Hi My table has composite pk, when i want to select based on one key i write select * from table where col1 = 'val1' and col2 = 'val2' when i have more then one pk like (val1, val2), (val3, val4), ... how can i write select with in so that i can get rows satisfing all the conditions. Shajeel
-
Hi My table has composite pk, when i want to select based on one key i write select * from table where col1 = 'val1' and col2 = 'val2' when i have more then one pk like (val1, val2), (val3, val4), ... how can i write select with in so that i can get rows satisfing all the conditions. Shajeel
select * from table where col1 in ('val1', 'val2') and col2 in ('val3', 'val4')
-
select * from table where col1 in ('val1', 'val2') and col2 in ('val3', 'val4')
-
Hi My table has composite pk, when i want to select based on one key i write select * from table where col1 = 'val1' and col2 = 'val2' when i have more then one pk like (val1, val2), (val3, val4), ... how can i write select with in so that i can get rows satisfing all the conditions. Shajeel
you can simply use:
select * from table where col1 IN('val1' , 'val2') and col2 IN ('val3' , 'val4')
it will work... Javed -
if will give me four combinations val1 and val3 val1 and val4 val2 and val3 val2 and val4 but i want only two combinations like here i just want first and third condition. Shajeel
you put dummy data in table then check the query will work fine...
-
you put dummy data in table then check the query will work fine...