sqlitefluttersqfliteflutter-moor

How to select rows that start with specified letter in Flutter using Moor


I have a table called Items with a column called Name. How can I do a query to get only items that start with a certain letter?

For example if I wanted all items that start with words R2. I tried the code below but its wrong :

 Future<List<Item>> getFilteredItems() => (select(items)..where((t) => t.Name.like('R2'))).get();

What is the proper to write the query?


Solution

  • All aspects of your questions beyond simple SQLite are beyond my knowledge.
    But turns out (confirmed by OP) that my first doubt solved the problem:

    Use 'R2%' instead of 'R2'. I.e. use the proper SQLite wildcard.