我正在尝试构建这种类型的查询:
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%"
在上面的查询中,'11'将来自用户输入,因此我写了这个但似乎抛出错误执行说SQLiteException:接近“%”:语法错误:这是我写的:
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+ '%'+"");
答案 0 :(得分:2)
也许你错过了引号,试试:
LIKE '"+ options.locNo + "%'");
在您的代码末尾。