在sqlite android查询上没有这样的列

时间:2014-02-12 14:09:57

标签: java android sqlite

我正在运行查询,但它不返回此类列。我将列复制并粘贴到sqlite查看器中,它正在运行,没有错误。

String SQL_QUERY = "SELECT m.* FROM '21_cars_models' as m INNER JOIN ( '41_cars_models_galleries' as mg 
INNER JOIN ( '24_galleries' as g 
INNER JOIN ( '26_galleries_pictures' as gp INNER JOIN '25_pictures' as p ON gp.picture_id=p._id ) 
ON g._id=gp.gallery_id ) ON mg.gallery_id=g._id ) 
ON m._id=mg.model_id WHERE m.brand_id LIKE '" + markaID + "'";

02-12 13:58:09.881: E/MYAPP(10962): android.database.sqlite.SQLiteException: no such column: gp.gallery_id (code 1): , while compiling: SELECT m.*  FROM '21_cars_models' as m INNER JOIN ( '41_cars_models_galleries' as mg INNER JOIN ( '24_galleries' as g INNER JOIN ( '26_galleries_pictures' as gp INNER JOIN '25_pictures' as p ON gp.picture_id=p._id ) ON g._id=gp.gallery_id ) ON mg.gallery_id=g._id ) ON m._id=mg.model_id WHERE m.brand_id LIKE '339'

编辑: 如果我删除所有INNER JOIN并运行它一切都很好。我无法理解为什么INNER JOIN的东西在吹。再次提醒一下,如果我直接将数据运行到数据库就好了......

1 个答案:

答案 0 :(得分:0)

问题是你不能用括号做内连接....我把我的查询改为

来自INNER JOIN b ON a.id = b.id INNER JOIN c ON c.id = b.id INNER JOIN d ON d.id = c.id

它完美地运作了......

感谢大家的时间......