2014-08-27 7 views
0

我有sqllite數據庫三個表:選擇值

topicTable 
    ----------- 
    _id 
    topic 

    table1 
    -------- 

    _id 
    topicid 
    topic_text 
    description 

    table2 
    ------- 
    _id 
    topicid 
    topic_translation 

什麼我做的是,當點擊某一主題我想從 table1topic_translationtopic_text,descriptiontable2

什麼我做的是:

MY_QUERY = "SELECT * FROM "+TABLE1+" a INNER JOIN "+ TABLE2+" b ON a.topicid=b.topicid WHERE a.topicid="+TOPICID; 
Cursor cursor = database.rawQuery(MY_QUERY,null); 

我的代碼有什麼問題?

+1

你有什麼問題? – 2014-08-27 17:32:27

+0

我收不到。 – 2014-08-27 17:36:05

+0

運行該查詢時得到了什麼? – mmlooloo 2014-08-27 17:43:11

回答

0

我想你想從table2table1topic_translationtopic_text,description通過table1 topicId

得到table1topicid,並作出這樣

"Select topic_text,description from table1 where topicid= topicid" 

同樣,對於表2

"select topic_translation from table2 where table2ID = topicid" 

一個簡單的查詢,在同時

0

試試這個選擇PLZ它與你的表

t1.topic_text,t1.description,t2.topic_translation工作從表1 T1 加入表2 T2加入topicTable T3上t1.topicid = t2.topicid = T3 ._id 其中t3._id ='1'