sqflite:如何制作“选择表”,例如word%word%;询问
相同的值中有两个或多个实例,
例如:
'INSERT INTO todos(title, entidad, categoria, emision) VALUES ("title1", "e1", "fire, water, sky", "emi1"');
我是Flutter和SQFlite的新手,并且在“类别”列中有多个实例,在某些插入物中,我在 类别列
我想要的是编码查询类型“像” SQLite句子,其中包含我想要的单词。
我只有此代码在我的dbhelper.dart中,它可以正常工作。
Future<List<todo>> categoriaIdiomas() async {
final db = await initializeDB();
//this is the query
final List<Map<String, dynamic>> queryResult =
await db.rawQuery('SELECT * FROM todos WHERE categoria=?', ['water']);
Map<String, dynamic> result = {};
for (var r in queryResult) {
result.addAll(r);
}
return queryResult.map((e) => todo.fromMap(e)).toList();
}
我想知道如何在sqflite中制作这样的事情:
“ 选择todos,其中类似于'%water%'
>的todos”
I am new to flutter and SQFlite, and I have multiple instances in my 'category' column, in some inserts I have two or more instances in the same value separated by ","
For example:
'INSERT INTO todos(title, entidad, categoria, emision) VALUES ("title1", "e1", "fire, water, sky", "emi1"');
In that example I inserted two values in the categories column
What i want is to code a query type "like" SQLite sentence, that contains the word i want.
I only have this code inside my dbhelper.dart, it works fine.
Future<List<todo>> categoriaIdiomas() async {
final db = await initializeDB();
//this is the query
final List<Map<String, dynamic>> queryResult =
await db.rawQuery('SELECT * FROM todos WHERE categoria=?', ['water']);
Map<String, dynamic> result = {};
for (var r in queryResult) {
result.addAll(r);
}
return queryResult.map((e) => todo.fromMap(e)).toList();
}
I would like to know how to make something like this in sqflite:
"SELECT todos WHERE categoria LIKE '%water%'
"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,删除
categoria
列中单词之间的空格,然后使用运算符LIKE
:First, remove the spaces between the words in column
categoria
and then use the operatorLIKE
: