从sqlite中的两个表中选择一个字段

时间:2015-11-27 03:32:46

标签: android sqlite listview

我有一个带有2个表的Sqlite数据库,Table1和Table2,都有一个字段" name",我的目标是显示与listview中每个表类似的名称

Cursor mCursor = db.rawQuery("select * from table1 JOIN table2 ON table1.name = table2.name where table2.name LIKE '%" + txtSearch + "%'", null);

它只显示表2中的结果:(请帮助

1 个答案:

答案 0 :(得分:-1)

也许问题来自你的加入声明。你可以尝试如下:

select t1.* from table1 t1 INNER JOIN table2 ON t1.name = table2.name where table2.name LIKE '%" + txtSearch + "%'"