0
附近的東西是錯誤的我在SQLite工作室做了這個查詢,現在我在Android Studio的Android應用程序中使用它。在SQLite Studio中,我得到了我需要的東西,但是每當我在Android上調用它時,它都會關閉應用程序。錯誤消息是:我在java中的這條sql語句中出現錯誤,但它在SQLite Studio中有效。它說'從'
無法啓動活動ComponentInfo {br.com.buraji.buraji/br.com.buraji.buraji.kanji_detalhes}:android.database.sqlite.SQLiteException:near「from」:語法錯誤(代碼1):編譯時:選擇Kunyomi.leitura,Kunyomi。從Kunyomi其中Kunyomi.idKanji = 1
select
Kunyomi.leitura,
\'くん\'as tipo,
VocabularioKun.vocabulario,
VocabularioKun.hiragana,
VocabularioKun.traducao,
VocabularioKun.exemploKanji,
VocabularioKun.exemploHiragana,
VocabularioKun.exemploTraducao
from Kunyomi
inner join VocabularioKun on Kunyomi._id = VocabularioKun.idKunyomi
where Kunyomi.idKanji = 1
union
select
Onyomi.leitura,
\'おん\' as tipo,
VocabularioOn.vocabulario,
VocabularioOn.hiragana,
VocabularioOn.traducao,
VocabularioOn.exemploKanji,
VocabularioOn.exemploHiragana,
VocabularioOn.exemploTraducao
from Onyomi join VocabularioOn on Onyomi._id = VocabularioOn.idOnyomi
where Onyomi.idKanji = 1
我使用的字符串如下:
Cursor c = myDataBase.rawQuery("select Kunyomi.leitura, \'くん\'as tipo, VocabularioKun.vocabulario, VocabularioKun.hiragana, VocabularioKun.traducao, VocabularioKun.exemploKanji, VocabularioKun.exemploHiragana, VocabularioKun.exemploTraducao from Kunyomi join VocabularioKun on Kunyomi._id = VocabularioKun.idKunyomi where Kunyomi.idKanji = 1 union select Onyomi.leitura,\'おん\' as tipo, VocabularioOn.vocabulario, VocabularioOn.hiragana, VocabularioOn.traducao, VocabularioOn.exemploKanji, VocabularioOn.exemploHiragana, VocabularioOn.exemploTraducao from Onyomi inner join VocabularioOn on Onyomi._id = VocabularioOn.idOnyomi where Onyomi.idKanji = 1", null);
我不知道爲什麼有這個第二Kunyomi。在錯誤信息中。它不在查詢中。請幫忙嗎?
請,格式錯誤信息,並嘗試沒有這兩條線執行查詢'\ 'おん\' 作爲TIPO,'和'\ 'くん\' 作爲TIPO,'可能它是轉義字符問題。 –
我試過了,錯誤仍然存在 – Ialy
在\'くん\'作爲tipo的行中,在'as'之前需要一個空格。就像你在工會的後半部分一樣。 –