2016-06-16 59 views
0

我stucked與此查詢沒有這樣的列:安卓:SQLiteException:當我使用子查詢

SELECT * FROM (

SELECT tab._id t_id, tab.name name, pics.pic1 pic FROM mushrooms tab 
JOIN mushrooms_pics pics ON t_id = pics.id WHERE t_id IN 
(SELECT item_id FROM coordinate WHERE type = "mushrooms") UNION 

SELECT tab._id t_id, tab.name name, pics.pic1 pic FROM berries tab 
JOIN berries_pics pics ON t_id = pics.id WHERE t_id IN 
(SELECT item_id from coordinate WHERE type = "berries") UNION 

SELECT tab._id t_id, tab.name name, pics.pic1 pic FROM herbs tab 
JOIN herbs_pics pics ON t_id = pics.id WHERE t_id IN 
(SELECT item_id from coordinate WHERE type = "herbs") 

) 
LEFT JOIN coordinate c ON t_id = c.item_id WHERE t_id IN 
(SELECT item_id from coordinate) 

查詢工作在「DB瀏覽器SQLite的」罰款,但在我的應用程序我得到一個錯誤,這裏是在LOGCAT中的錯誤:

android.database.sqlite.SQLiteException: no such column: herbs (code 1): , while compiling: SELECT name FROM(SELECT tab._id t_id, tab.name name, pics.pic1 pic FROM mushrooms tab JOIN mushrooms_pics pics ON t_id = pics.id WHERE t_id in (SELECT item_id from coordinate WHERE type = mushrooms) UNION SELECT tab._id t_id, tab.name name, pics.pic1 pic FROM berries tab JOIN berries_pics pics ON t_id = pics.id WHERE t_id in (SELECT item_id from coordinate WHERE type = berries) UNION SELECT tab._id t_id, tab.name name, pics.pic1 pic FROM herbs tab JOIN herbs_pics pics ON t_id = pics.id WHERE t_id in (SELECT item_id from coordinate WHERE type = herbs)) LEFT JOIN coordinate c on t_id = c.item_id WHERE t_id in (SELECT item_id from coordinate) 

有什麼想法我該如何解決這個問題? 謝謝;)

回答

1

在SQL中,字符串使用單引號。 雙引號用於轉義表名或列名。

(SQLite允許在兩種情況下,但這並不幫助在一個模棱兩可的上下文。)

+0

謝謝,它幫助! – Nemesis