mysql1_dart
mysql1_dart copied to clipboard
i'm not able to update query with dynamic column name
var res = await conn.query( "UPDATE levelDetails SET ?=? WHERE userid=?", [Level, percentage, userId]);
Exception has occurred. MySqlException (Error 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?=? WHERE userid=?' at line 1)
Please help me..
im not able to update query with dynamic column name
You can try this.
if ( x == 1 ) fieldName = "field1";
else if ( x == 2 ) fieldName = 'field2';
String cQ = "UPDATE levelDetails SET $fieldName=? WHERE useriid = ?";
await.conn.query(cQ,[Level, percentage, userId]); I Hope it works for You !!