Hi there....i just love your videos. Can u tell how to execute this query "Select max(tran_id) from transaction"; i want to get only single id from the table. Thank you
Hi, thank you so much for such great tutorial. One doubt though - why did you add the where clause after the order statement at 15:14? I believe that the ordering should be done with the least data available and I would have approached it with where first and then order by. Can you please guide?
super late to this but he’s just constructing the SQL statement. It doesn’t mean that the operations will happen in this order, that’s up to the database engine to decide. Once he’s done adding all the parts of the SQL statement, it’s sent to the engine and then it will filter first and then order.
Hi, Good Tutorials.... I have a Doubt.. when i place & simbol (AND condition) in my code this shows syntax error.. how can I solve this issue? "select(animals)..where((a) => a.isMammal.not() & a.amountOfLegs.equals(4))"
Hi there, how can i perform SELECT SUM(price) FROM TABLE_NAME WHERE completed = 1; in moor. From the Video I can only see that the query returns List/More than one rows.
moor_flutter 2.0.0 return customSelectQuery( "SELECT SUM(${carts.price.$name}) as total from ${carts.$tableName} WHERE ${carts.completed.$name} = ?''', variables: [Variable.withBool(true)], readsFrom: {carts}, ).getSingle().then((row) => row.data["total"] as double);
so my problem was I made id as autoincreament and set isCompleted field's default value to be false. but while inserting a new task in onSubmit callback it requires to pass both id and isCompleted columns as they are required field in generated dart file What i did is, I modified generated dart file by setting isCompleted = false and id = 1. On doing this, my app run sucessfully. But this doesnot allow me to add another task as there can't be two task with same id. How do i solve this error? I copied everthing from resocoder website
Can someone show me an example to make manual select in moor? Something that run this query "Select field1, field2, field3 from table where field1 = null"?
final query = customSelect('SELECT * FROM tasks WHERE completed = 1 ORDER BY due_date DESC, name;', readsFrom: {tasks},); return query .map((row) => Task.fromData(row.data, db)).watch();
Future clearTables() { return transaction(() async { await customUpdate( 'DELETE from ${tasks.$tableName}', updates: {tasks}, ); .... clear other tables.... }); } There could be better ways in moor. But this works for me.
did you try select(tasks) ..where((t)=>column_1_condition) ..where((t)=>column_2_condition) OR you could use moor's customSelectQuery for more query flexibility