Currently my table have the following fields
id,medium(json) ,material(json),subject,category
I would like to perform a filter based on user inputs that is if user input is present on particular field perform a where sql based on that input
minimal code
var sql = 'SELECT * FROM table';
//category is present in userinput
if(category){
sql+='WHERE category=category';
}
//subject is present in userinput
if(subject){
sql+='WHERE subject=subject'
}
if(material){
sql+='WHERE material=material'
}
if(medium){
sql+='WHERE medium=medium'
}
db.query(sql,function(error,result){
console.log(result);
});
But i confused where can i put AND in sql query when any two of the user input is present or user input contains all the fields


expresstag. Its a javascript framework over nodematerialandmediumcolumns are JSON. So there is a whole bunch of extra stuff needed just for that column to be used in a search criteria