title: How to use variables for values in SQLite?
body: <p>I am trying to incorporate variables into a query to make it easier to manage. I followed the guidelines outlined in <a href="https://stackoverflow.com/a/24663140/6110631">this answer</a> and tried to implement them.</p>
  
  <p>I am using SQLite for this so I am stuck with its limitations, but it looks like some people have gotten some workarounds to work. The following query runs successfully, but does not return any records. If I replace the variable names in my WHERE clause with 'John' and 'Smith' respectively, the query returns 1 record, but if I use the variable names that I had created instead, 0 records are returned. Removing the quotes around the variables does not make it work.</p>
  
  <pre><code>CREATE TEMP TABLE IF NOT EXISTS _Variables (Name TEXT PRIMARY KEY, Value TEXT);
  INSERT OR REPLACE INTO _Variables VALUES ('VarFirstName', 'John');
  INSERT OR REPLACE INTO _Variables VALUES ('VarLastName', 'Smith');
  
  SELECT LastName,FirstName,BirthYear,(strftime('%Y', date('now')) - BirthYear) AS Age,LocalExp,TotalExp,TotSalary,TotFringe,WorkLocationName,SchoolName
  FROM DPISTAFF2008_2009
  WHERE DPISTAFF2008_2009.FirstName = 'VarFirstName' AND DPISTAFF2008_2009.LastName = 'VarLastName'
  
  ;DROP TABLE _Variables;
  </code></pre>
  
  <p>I am assuming that my WHERE clause is not properly referring to the variables I created. What is the proper way to call them? Doing what the answer linked above says does not seem to work for me.</p>
  
  <p>Commenting out <code>;DROP TABLE _Variables;</code> doesn't change the outcome.</p>