Reputation: 19
c=MyDB.rawQuery("SELECT Distance FROM " +
Table1 + "WHERE Source = '" + source + "' AND Distance = " +
distance + " ' ", null);
distance = c.getFloat(c.getColumnIndex("Distance"));
Upvotes: 0
Views: 208
Reputation: 5819
You're missing an apostrophe before the distance value, and a space after the table name.
However, this way of constructing queries makes you prone to SQL injection attacks. Instead, use proper parameters. How to do this will be documented in the library you are using.
Upvotes: 0
Reputation: 43088
c=MyDB.rawQuery("SELECT Distance FROM " + Table1 + " WHERE Source = '" + source + "' AND Distance = '" + distance + " ' ", null);
Pay attention to the space before WHERE
keyword and " ' " after Distance = .
Also, better to use not rawQuery, but query method, as it use prepared statement, which is more safe.
Upvotes: 2