android - View 中没有此类列错误

标签 android sql database sqlite

我在 sqlite - android 中创建了两个 View ,但是当我创建第二个 View 时 我收到错误

No Such Coulmn : template_contact_info.tmp_text as text and template_contact_info.tmp_link as link

即使这两个列都存在于 template_contact_info 中,并且 template_contact_view 已成功创建。但仍然不知道为什么我会收到 No such column 错误。

这是 View 代码

第一眼

db.execSQL("CREATE VIEW IF NOT EXISTS 

template_contact_info AS 

SELECT

template_info.tmp_text as tmp_text ,
template_info.tmp_link as tmp_link , 
template_info.tmp_id as temp_id , 
template_info.tmp_type as tmp_type , 
template_contact._id as _id  
from template_info , template_contact 

where  template_info.tmp_id = template_contact.tmp_id");

第二个 View //这里我收到一个错误

db.execSQL("CREATE VIEW IF NOT EXISTS 

template_contact_assign AS SELECT 

contact_info.c_number as number , 
contact_info.c_name as name ,  
contact_info.c_id as conid, 
contact_info._id as cid, 
template_contact_info.tmp_type as type , 
template_contact_info.temp_id as tempid ,
template_contact_info.tmp_text as text ,
template_contact_info.tmp_link as link 
FROM contact_info LEFT JOIN template_contact_info
ON contact_info._id = template_contact_info._id");

最佳答案

//你正在搭便车

template_contact.tmp_id

//创建时你正在使用temp_id而不是 tmp_id

template_contact_info.temp_id

编辑:

数据库已经存在,所以您需要卸载/删除数据库以重新创建修改后的表。

通过命令实用程序“adb shell or via eclipse using the file explorer. The database resides in under”删除数据库'/数据/数据//数据库'。

对于 adb use rm <db_name>

关于android - View 中没有此类列错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10916180/

相关文章:

mysql - 使用子查询与 LEFT JOIN 一起选择 MAX 值

mysql - MySql 中时间戳的性能问题

php - HTML/PHP Survery 没有正确地从表中传递 ID

php - 代码点火器 : How to show logged In User Name in every methods (or view page) without repeating same code in every function

android - 谷歌地图在 actionbarsherlock 选项卡中

android - 处理程序运行然后关闭总 Activity 媒体文件继续如何解决问题

asp.net - 显示错误填充 : SelectCommand. 连接属性尚未初始化

android - Flutter 警报管理器缺少插件异常

java - 如果每行包含不同数量的 View ,如何在 tablelayout 中制作相同大小的 View ?

java - 如何在preparedStatement中将字符编码格式更改为UTF-8。