title: How to Write Sql RawQuery in Android
body: <p>I have a query which is working in Sqlite Browse but when I write same in Android it is not working properly. Below is the SQL query I have written</p>
  
  <pre><code>SELECT value 
  FROM current_tab 
  WHERE variable = 'currentVehicleSpeed' 
    AND ABS(1 - value) = (SELECT MIN(ABS(1 - value)) 
                          FROM current_tab 
                          WHERE variable = 'currentVehicleSpeed' 
                            AND ABS(1 - value) &lt;= 5)
  </code></pre>
  
  <p>I want above query inside <code>db.rawQuery(...)</code>.</p>
  
  <p>This is how I have done it:</p>
  
  <pre><code>db.rawQuery("SELECT value FROM current_tab WHERE variable = '" + var + "' AND ABS( '"
                          + valueDouble + "' - value )=(SELECT MIN(ABS( '"
                          + valueDouble + "' - value )) FROM current_tab WHERE variable = '" + var + "') AND ABS( '" + valueDouble + "' - value &lt;=5) ", null);
  </code></pre>
  
  <p>where 'value' and 'variable' are the column name</p>
  
  <p><code>current_tab</code> is the table name </p>
  
  <pre><code>var = "currentVehicleSpeed" and valueDouble = 1
  </code></pre>
  
  <p>Thanks for any help</p>