Put correct variable in SQL query when using SQL operators