简体   繁体   English

如何在android中比较第一个表ID和第二个表类别ID并显示数据category_id明智的数据库

[英]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.

相关问题 按category_id查找Hibernate,春季 - Find By category_id Hibernate, Spring hibernate.MappingException:外键:category [CATEGORY_ID]))的列数必须与引用的主键相同(category [STOCK_ID,CATEGORY_ID]) - hibernate.MappingException:Foreign key:category[CATEGORY_ID]))must'vesame numberof columns as thereferenced primarykey(category[STOCK_ID,CATEGORY_ID]) java.sql.SQLException: 列 'Max(category_id' 未找到) - java.sql.SQLException: Column 'Max(category_id' not found 如何在JSP Spring MVC中显示类别名称而不是类别ID - How to display category name instead category id in jsp spring mvc 如何在Android中使用数据库明智地删除数据ID而不是位置 - how to remove data id wise instead of position using database in android 使用Java或android中的数据库表获取包含可识别数据的表ID - Getting table id with repecive data using database table in java or android org.postgresql.util.PSQLException:错误:“ category_id”列中的空值违反了非空约束 - org.postgresql.util.PSQLException: ERROR: null value in column “category_id” violates not-null constraint 如何将ID与本地数据库中的表列值进行比较? - How to compare id with the table column values in local database? jComboBox 在 java netbeans 中将类别 ID 添加到数据库中而不是类别名称 - jComboBox Instead of category name add category ID into the database in java netbeans 通过第一个表中的 ID 从第二个表中获取值 - Get values from second table by ID that is in first table
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM