title: optional search parameters in sql query and rows with null values
body: <p>Ok here is my problem :</p>
  
  <p>Before i start the description, let me to tell you that I have googled up a lot and I am posting this question for a good optimal solution :)</p>
  
  <p>i am building a rest service on WCF to get userProfiles... the user can filter userProfiles by giving something like userProfiles?location=London</p>
  
  <p>now i have the following method</p>
  
  <pre><code>GetUserProfiles(string firstname, string lastname, string age, string location)
  </code></pre>
  
  <p>the sql query string i built is:
  <code>select firstname, lastname, .... from profiles where (firstName like '%{firstname}%') AND (lastName like '%{lastName}%')</code> ....and so on with all variables being replaced by string formatter.</p>
  
  <p>Problem with this is that it filters any row having firstname, lastname, age or location having a null value....</p>
  
  <p>doing something like <code>(firstName like '%{firstName}%' OR firstName IS NULL)</code> would be tedious and the statement would become unmaintanable! (in this example there are only 4 arguments, but in my actual method there are 10)</p>
  
  <p>What would be the best solution for this?....How is this situation usually handled?</p>
  
  <p>Database used : MySql</p>