I have a very simple SQL search query as follows.
$sql =
"
SELECT *
FROM suppliers
WHERE
product_categories LIKE '%$product_categories1%'
AND agentid=?????
";
In the part of the query where agentid=???
I need to get the following conditionality to work.
If some $var
is (say) 1 then agentid !=' '
If same $var
is (say) 2 then agentid =' '
The purpose of this query is . .. if !=''
the query returns ALL rows where there is an agentid value (!='')
or SQL returns no rows at all if agentid is set to (=' ')
.
My problem is how to write the SQL to introduce this simple condition?
PS I am aware of the <>
sql alternative.