0

When I run Query fetch Details with two conditions? getting error

Unhandled Exception:

DatabaseException(near "2019": syntax error (code 1):

, while compiling: 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);

  }

1 Answer 1

1
SELECT monthyear FROM $table WHERE $shopid=$uid AND 
 $monthyear="+"'$month'",null)

Add just single qoute in logic query when 'condition1' and 'condition2'

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);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.