Home > database >  Use And and or operator together in sql
Use And and or operator together in sql

Time:12-31

Is there any way that i could use and and like operator with or to get desired

Select * from table where column1 = 1 and column2 =10 and column3 like '%we%' or column3 like '%ws%'

Need to use or in just 3rd column but with and of other 3 Columns

CodePudding user response:

Try this:

Select * from table where column1 = 1 and column2 =10 and (column3 like '%we%' or column3 like '%ws%');

That's how you can get your desired output.

CodePudding user response:

Instead of using two like with "OR" you can also follow below syntax.

Select * from table where column1 = 1 and column2 =10 and column3 like '%[w][es]%'
  • Related