sqflite:如何在同一rawquery中使用两个列进行选择
我想从与操作员或操作员的2列中接收信息,但我无法视觉效果。
我的列标题
和我的列cancoria
。我想制作一个影响这两个列的选择,类似的内容:selec *从title或cancoria中...
这就是我所拥有的:
final List<Map<String, dynamic>> queryResult = await db
.rawQuery('SELECT * FROM todos WHERE title like ?', ['%'+queryCourse+'%']); //here i want to complete the select with both columns
I want to receive info from 2 columns with OR operator, but i can not visualice.
I have my column title
and my column categoria
. I want to make a select that affects both columns, something like this: selec * from title OR categoria where ...
this is what i have:
final List<Map<String, dynamic>> queryResult = await db
.rawQuery('SELECT * FROM todos WHERE title like ?', ['%'+queryCourse+'%']); //here i want to complete the select with both columns
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
或
对2列操作员:或:
我假设对于这两个列,您都将使用相同的参数
queryCourse
。如果没有,请使用所拥有的参数更改参数。
Use the
OR
operator for the 2 columns:or:
I assumed that for both columns you will use the same parameter
queryCourse
.If not, then change the parameters with the ones you have.
您想要工会所有操作员。
参见
https://www.sqlitetoriorarorial.net/sqlite-net/sqlite-union/
他们的示例是:
注意,列必须“匹配”。在这里,我使用“姓氏”。
与列不同,您不能“联合”。在SQLiteTutorial的示例中,第三列是“字符串” ...它可以具有不同的值,但是在Select语句中必须是相同的“数据类型”和序列位置。
请务必阅读有关工会和“联盟”之间不同的文档。
对于“ where”条件,您必须在联合的每个“部分”上指定所有
https://www.techonthenet.com/sqlite/union_all.php
;
You want the UNION ALL operator.
see
https://www.sqlitetutorial.net/sqlite-union/
Their example is:
Note, the columns must "match". Here I use "lastName".
You cannot "union all" unlike columns. in the example from the sqlitetutorial, the third column is a "string"... it can have different value(s), BUT it must be the same "data-type" and ordinal position in the SELECT statement.
Be sure to read the documentation on the different between UNION and 'UNION ALL'.
For the "where" condition, you'll have to specify on each "part" of the UNION ALL
https://www.techonthenet.com/sqlite/union_all.php
;