title: IF statement inside where clause in SQL
body: <p>I'm developing a calendar app. It stores times in two formats. The table have following columns <code>title, startDate, startTime</code>. If the user provides start time plus start date. The database stores UNIX time stamp(number of seconds since UNIX epok) in the column <code>startTime</code>, while startDate is <code>NULL</code>. If the user only provide a start date,  the database stores the date in format <code>nnnn-mm-dd</code> in <code>startDate</code> and <code>NULL</code> in ´startTime`. I have this DB structure, because it's easier to display times around the world, because different timezones have different daylight saving times.</p>
  
  <p>I want select the events that are occurring after a specified date. The client computer provide the server with a UNIX timestamp of the beginning of that day(<code>$unix</code>) and a date(<code>$date</code>) in the format <code>nnnn-mm-dd</code> to select the correct dates.</p>
  
  <p>The problem is, I don't know how to select those days that are occurring as specified above. This solution is not applicable for me, even though it works:</p>
  
  <pre><code>SELECT *
    FROM events
   WHERE startDate &gt;= '$date'
     OR startTime &gt;= '$unix'
  </code></pre>
  
  <p>The thing is I have in some rows where unix time stamp is provided in <code>startTime</code>, I also have a date provided in <code>startDate</code> and other reason I which I don't want to explain. And because of that I can't use the solution above.</p>
  
  <p>I need some kind of solution that have an IF statement inside the Where clause like:</p>
  
  <pre><code>SELECT *
    FROM events
   WHERE IF(startTime = NULL, startDate &gt;= '$date', startTime &gt;= '$unix')
  </code></pre>
  
  <p>I'm just guessing this solution. But is it right?</p>