当我在两个条件下运行查询获取详细信息时?出错
未处理的异常:
DatabaseException(“ 2019”附近:语法错误(代码1):
,在编译时:SELECT monthyear FROM metersd WHERE shopid=1 AND monthyear = August 2019) sql 'SELECT monthyear FROM metersd WHERE shopid=1 AND monthyear = August 2019' args []}
SELECT monthyear FROM metersd WHERE shopid=1 AND monthyear = August 2019
Future<MeterData> getMonthYear(int uid,String month) async {
var dbClient = await db;
var result = await dbClient.rawQuery("SELECT monthyear FROM $table WHERE $shopid=$uid AND $monthyear = $month");
if (result.length == 0) return null;
return MeterData.fromMap(result.first);
}
答案 0 :(得分:1)
SELECT monthyear FROM $table WHERE $shopid=$uid AND
$monthyear="+"'$month'",null)
当'condition1'和'condition2'时在逻辑查询中仅添加单个qoute
Future<MeterData> getMonthYear(int uid,String month) async {
var dbClient = await db;
var result = await dbClient.rawQuery("SELECT monthyear FROM $table WHERE $shopid=$uid AND $monthyear="+"'$month'",null);
if (result.length == 0) return null;
return MeterData.fromMap(result.first);
}