0

我使用 SQLdelight 创建 sql 代码,比如

SELECT * FROM CoachService WHERE shop_id in (?) and brand_id = ?

我查询喜欢:

briteDatabase.createQuery(CoachService.TABLE_NAME, CoachService.GETBYBRANDIDANDSHOPS,  "'1','5','11'","2");

但结果是空的。然后,我像这样改变sqlcode

SELECT * FROM CoachService WHERE shop_id in ('1','5','11') and brand_id = ?

它返回我 3 个结果。为什么?

4

1 回答 1

0

当您传入查询参数时,它会被 android 绑定转换为字符串。因此,当您传入"'1','5','11'","2"它时,它会在查询中显示为

SELECT * FROM CoachService WHERE shop_id in (''1','5','11'') and brand_id = ?

或类似的东西,其中 '1','5','11' 实际上是一个完整的字符串。

于 2016-10-13T04:09:25.183 回答