检查值为null或不在条件MySQL的内部

I have a advanced search form which passes many variables to another page next.php.

My question is I want to check the variable is null or not inside query .

Can i use like this or is there any function like this??

$price=$_GET['price'];
$query="SELECT * FROM products WHERE (if price!='' { $price; } )";

Simply i want is if $price is null , i do not want check in where condition because it affects results.

How to do this guys??

Give me a solution

Thankss

Just check BEFORE querying anything. Why would you waste time in generating query if you have nothing to generate with?

$price=$_GET['price'];
if($price !== NULL) {
   //do stuff
}