Line selection, where 1 = a, 2 = b OR 1 = b, 2 = a

I have a form that gives me information like INPUT1, INPUT2. I need to select from COL1 and COL2 where COL1 = INPUT1, COL2 = INPUT2 INPUT1, INPUT2. I need to select from COL1 and COL2 where COL1 = INPUT1, COL2 = INPUT2 or vice versa, COL1 = INPUT2, COL2 = INPUT1.

+4
source share
3 answers
 SELECT * FROM table WHERE (COL1 = INPUT1 AND COL2 = INPUT2) OR (COL1 = INPUT2 AND COL2 = INPUT1); 
+7
source
  SELECT * FROM table
 WHERE (COL1 = INPUT1 AND COL2 = INPUT2) 
    OR (COL1 = INPUT2 AND COL2 = INPUT1) 
+3
source

select * from table_name where (COL1 = INPUT1 AND COL2 = INPUT2) OR (COL1 = INPUT2 AND COL2 = INPUT1);

0
source

Source: https://habr.com/ru/post/1337626/


All Articles