[英]how to compare first table id and second table category id and display data category_id wise database in android
I have create two table like this我已经创建了两个这样的表
** i have click Freedom Fighters only Mahatma Gandhi then i have click Sports Person only show Sania Mirza** ** 我点击了只显示圣雄甘地的自由战士,然后我点击了只显示 Sania Mirza 的体育人**
category:ID | NAME
people:ID|NAME|CATEGORY_ID
My first table data我的第一个表数据
"1" "Freedom Fighters"
"2" "Sports Person"
"3" "Scientist"
"4" "Politicians"
"5" "Celebrities"
My second table data我的第二个表数据
NAME category_id
"Mahatma Gandhi" "1"
"Sania Mirza" "2"
"C. V. Raman" "3"
"Swami Vivekananda" "4"
**My query is ** **我的查询是**
Cursor cursor = db.rawQuery("select * from people where category_id = (select id from category)", null);
But only show the first row of thesecond table但只显示第二个表的第一行
select * from people where category_id in (select id from category)
在这个查询中你得到你需要的......
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.