vendredi 15 janvier 2016

String concatenation issue with Like query

I am trying to construct this type of query :

SELECT DISTINCT l.accession_key,l.lat, l.lon,l.site, l.location,s.overiew_date FROM g_l AS l INNER JOIN g_s AS s on l.accession_key = s.accession_no WHERE l.lat!=0 AND l.lon!=0 AND l.site='K' AND l.isLive='L' AND l.location LIKE "11%" 

In the above query the '11' will be coming from the user input, hence i wrote this but seems it throws error executing saying SQLiteException: near "%": syntax error: Here' s what i wrote:

var result = this.getRows("SELECT DISTINCT l.accession_key,l.lat, l.lon,l.site, l.location,s.overiew_date FROM g_l AS l INNER JOIN g_s AS s on l.accession_key = s.accession_no WHERE l.lat!=0 AND l.lon!=0 AND l.site='" + options.site + "' AND l.isLive='L' AND l.location LIKE "+ options.locNo+ '%'+"");

Aucun commentaire:

Enregistrer un commentaire