如何在android中比较第一个表id和第二个表类别id以及显示数据category_id wise数据库

时间:2016-10-05 06:56:42

标签: java android mysql database sqlite

我创建了两个这样的表
**我点击自由战士只有圣雄甘地然后我点击运动人只显示Sania Mirza **

category:ID | NAME
people:ID|NAME|CATEGORY_ID

我的第一个表数据

"1" "Freedom Fighters"
"2" "Sports Person"
"3" "Scientist"
"4" "Politicians"
"5" "Celebrities"

我的第二个表数据

 NAME               category_id
"Mahatma Gandhi"    "1"
"Sania Mirza"       "2"
"C. V. Raman"       "3"
"Swami Vivekananda" "4"

**我的查询是**

 Cursor cursor = db.rawQuery("select * from people where category_id = (select id from category)", null);

但只显示第二个表的第一行

1 个答案:

答案 0 :(得分:1)

select * from people where category_id in (select id from category)

在此查询中,您需要......