title: Variable sqlite3 query in nodejs
body: <p>I'm building a simple form using node.js that asks for the things you'd expect:
  - First Name
  - Last Name
  - Address</p>
  
  <p>and doing a query against a sqlite3 database with fields named firstName, lastName, address. I would like to mix and match queries, though — you can search for just lastName OR firstName along with lastName OR lastName with portion of street address, etc.</p>
  
  <p>Writing separate queries for each case would be annoying, but I'm not sure how else to do it. In code, the following works if I enter first name or last name:</p>
  
  <pre><code>db.serialize(function() {
     db.each("SELECT rowid AS id, lastName, firstName FROM county WHERE firstName = ? OR lastName = ?", firstName, lastName, function(err, row) {
     console.log(row.id + ": " + row.firstName + ' ' + row.lastName);  
     }
  }
  </code></pre>
  
  <p>but, if I enter first name and last name, I want that to be AND instead of only return rows where both match. If I do an AND in that clause, it returns nothing if I leave one of the fields blank.</p>
  
  <p>Am I just missing a trick in constructing my query?</p>
  
  <p>Thanks!</p>