I'm trying to write a MySQL Statement for and advanced search bar. Essentially I need it to only include sections of a WHERE statement, if a variable is not blank.

This is where I've given up:

```
$sql = "SELECT * FROM Products WHERE if($brand != '', brand='$brand' AND, brand LIKE _%)";

```

Something like this is what I need:

```
SELECT * FROM Products WHERE (brand = variable)<-[ONLY IF VARIABLE IS NOT BLANK]

```

I'm really trying to refrain from having a binary system with thousands of IF statements.

EDIT:

It's also worth nothing that I will need over 10 If-Statements within this WHERE

EDIT:

Also, the variable I'm checking to be blank is stored locally in the PHP not on the MySQL Server. To try to be more specific to what I'm looking for:

```
$brand = "Samsung";
$sql = "SELECT * FROM Products WHERE [IF BRAND != NULL USE THIS STRING FOR WHERE STATEMENT -> brand='$brand'] [SECOND IF] [THIRD IF]";

```