Using OR in LIKE Query in MySQL to compare multiple fields -


i thought use or in like statment query things in mysql. so, if wanted compare multiple fields in row 1 keyword or term:

select * mytable column1 or column2 '%keyword%';  

and if had array of words compare:

select * mytable column1 or column2 '%keyword1%'  , column1 or column2 '%keyword2%'; 

i don't believe syntax correct, however. there efficient method of writing aside like:

select * mytable column1 '%keyword1%' or column2  '%keyword1%' , column1 '%keyword2%' or column2 '%keyword2%'; 

am going correctly?

use this::

select * mytable (column1 '%keyword1%' or column2  '%keyword1%') , (column1 '%keyword2%' or column2 '%keyword2%'); 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -