开发者

Selecting a row where, 1=a, 2=b OR 1=b, 2=a

I have a form that is giving me information like INPUT1, INPUT2. I need to select from COL1 and COL2 开发者_开发知识库where COL1 = INPUT1, COL2 = INPUT2 or the other way around, COL1 = INPUT2, COL2 = INPUT1.


SELECT * FROM table WHERE 
                      (COL1 = INPUT1 AND COL2 = INPUT2) 
                   OR (COL1 = INPUT2 AND COL2 = INPUT1);


SELECT * FROM table
WHERE ( COL1=INPUT1 AND COL2=INPUT2 ) 
   OR ( COL1=INPUT2 AND COL2=INPUT1 ) 


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜