IF and ELSE in SQL WHERE CLAUSE

Wednesday, November 4, 2015

I have a quick question if I need a sql query to first check for a match WHERE column is eqaul to X1 and if no match here search every row.



This is my current SQL statement.



SELECT name, image_url FROM `".$config_databaseTablePrefix."products` WHERE name LIKE '$queryString%' LIMIT $numberOfProducts


But I need it to check for a match WHERE e.g columnName = XX if no match found look all other rows.



How can i achieve this?

0 comments:

Post a Comment