我使用SQLdelight创建sql代码,如
SELECT * FROM CoachService WHERE shop_id in (?) and brand_id = ?
and I query Like:
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个结果。为什么?
当你传入一个查询参数时,它会被android绑定转换成一个字符串。所以当你传入"'1','5','11'","2"
时它在查询中显示为
SELECT * FROM CoachService WHERE shop_id in (''1','5','11'') and brand_id = ?
或类似的东西,其中'1','5','11'实际上是一个完整的字符串