IF and ELSE in SQL WHERE CLAUSE

Wednesday, November 4, 2015

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, and if no match is found look in all other rows.



How can I achieve this?

0 comments:

Post a Comment