Issue
I want to search database based on the keyword. if it title or content contains the keyword then return the data. but it send backs nothing.
static Future<List<Note>> searchDocuments(String? keyword) async {
final database = await DatabaseHelper.database();
List<Map<String, dynamic>> allDocuments = await database.rawQuery(
'SELECT * FROM docs WHERE title=? and content=?',
['$keyword%', '$keyword%']);
checked - doesn't work.
Solution
This works.
await database.rawQuery(
'SELECT * FROM docs WHERE title LIKE ? OR content LIKE ?',
['%$keyword%', '%$keyword%']);
Answered By - Mahi
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.