2014-08-27 43 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'