执行此查询:
从菜单项中选择 *
return new Promise((resolve, reject) => {
db.transaction((tx) => {
tx.executeSql(
"select * from menuitems",
[`%${query}$%`],
(_, { rows }) => {
useDevLogData(rows._array, "filterByQueryAndCategories rows._array");
}
);
}, reject);
});
我有这组结果:
[
{
"id": 1,
"uuid": "1.0",
"title": "Spinach Artichoke Dip",
"price": "10",
"category": "Appetizers"
},
{
"id": 2,
"uuid": "2.0",
"title": "Hummus",
"price": "10",
"category": "Appetizers"
},
...
]
但是当我这样做的时候我没有结果:返回空[]
return new Promise((resolve, reject) => {
db.transaction((tx) => {
tx.executeSql(
"select * from menuitems WHERE title LIKE ?",
[`%${query}$%`],
(_, { rows }) => {
useDevLogData(rows._array, "filterByQueryAndCategories rows._array");
}
);
}, reject);
});
此外,我需要合并这个搜索文本,例如%菠菜%查询过滤类别的一个类别数组,例如.[“开胃菜”,“沙拉”],我如何查询过滤类别列基于字符串数组?并基于此,我需要查询字段标题?我需要这样做:
"select * from menuitems where title LIKE %Spinach% AND category LIKE ["Appetizers", "Salads"]"
1条答案
按热度按时间krcsximq1#
对不起有错字,解决它这样,我有3最大类别:
可能会帮助像我这样的SQL新手,这似乎对我现在很有效