我无法在sqlite android中运行查询,它抛出以下错误:
android.database.sqlite.SQLiteException:没有这样的表:table1.item1(代码1):,而编译时:SELECT * from table1,table2其中table1.item1不在table2.item1中
我的原始查询是:
Database.rawQuery("SELECT * from "+ TABLE1 +", "
+TABLE2+" where "+ TABLE1 +"" + "."+ ITEM1 +" not in "
+ TABLE2 +"."+ ITEM1, null);
字符串常量:
TABLE1= "table1", TABLE2="table2", ITEM1= "item1"
我想要table1中的所有行,而item1不在table2的item1值列表中。
我是否需要添加一些GROUP BY语句?
如果这是您要寻找的,这将是您的查询:
SELECT * FROM table1 WHERE item1 NOT IN (SELECT item1 FROM table2)
您的“ SELECT * FROM table1,table2”将为您提供table1和table2的每个返回记录的组合。并非经常如此。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句