数据库SQL语句错误
Caused by: android.database.sqlite.SQLiteException: near "where": syntax error(Sqlite code 1): , while compiling: select * from wenjian where 1=1 and where cehao=1288,(OS error - 2:No such file or directory)
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1334)
at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1268)
<1>上面是数据库语句写错了:select * from wenjian where 1=1 and where cehao=1288
应该只用一个where :select * from wenjian where 1=1 and cehao=1288
Caused by: android.database.sqlite.SQLiteException: unrecognized token: "01端"(Sqlite code ): , while compiling: select * from wenjian where = and duanhao=01端,(OS error - :No such file or directory)
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:)
at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:)
at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:)
at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:)
Caused by: android.database.sqlite.SQLiteException: no such column: LOG(Sqlite code ): , while compiling: select * from wenjian where = and gongneng=LOG,(OS error - :No such file or directory)
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:)
at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:)
at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:)
at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:)
最后解决:
select * from wenjian where 1=1 and cehao=1288
这里的数据库表字段都是定义为vachar ,但是cehao字段里面都是存储的数字,这里在拼接sql语句时,这样写是可以运行正确的。
但是当字段存储的数据不是数字,而是字符串的话,需要加单引号(英文单引号不区分左右的),语句应该为:
select * from wenjian where 1=1 and cehao=1288 and duanhao=‘01端’
基础语句不会啊……浪费了2个小时。
学习……
数据库SQL语句错误的更多相关文章
- 用PowerDesign反向生成数据库Sql语句问题
在用Pd15反向生成数据库时,生成的Sql语句在Sql Server Manager Studio里面报错,根本就执行不了.数据库用的是Sql Server 2008 R2.经过一番修 ...
- 学生选课数据库SQL语句45道练习题整理及mysql常用函数(20161019)
学生选课数据库SQL语句45道练习题: 一. 设有一数据库,包括四个表:学生表(Student).课程表(Course).成绩表(Score)以及教师信息表(Teacher).四 ...
- MySQL中执行sql语句错误 Error Code: 1093. You can't specify target table 'car' for update in FROM clause
MySQL中执行sql语句错误 Error Code: 1093. You can't specify target table 'car' for update in FROM clause 201 ...
- MySQL 数据库SQL语句——高阶版本2
MySQL 数据库SQL语句--高阶版本2 实验准备 数据库表配置: mysql -uroot -p show databases; create database train_ticket; use ...
- MySQL 数据库SQL语句——高阶版本1
MySQL 数据库SQL语句--高阶版本 实验准备,数据表配置 mysql -uroot -p show databases; create database train_ticket; use tr ...
- 数据库添加数据II及SQL语句错误
前些时候,写的代码(数据库添加数据I),往数据库添加数据都是很基本的一条一条地添加.但是平常用于测试时,总不可能一条一条地添加测试数据吧,然后我就尝试着一次性添加几百上千条,但是再次操作的时候,就出问 ...
- ORACLE数据库SQL语句的执行过程
SQL语句在数据库中处理过程是怎样的呢?执行顺序呢?在回答这个问题前,我们先来回顾一下:在ORACLE数据库系统架构下,SQL语句由用户进程产生,然后传到相对应的服务端进程,之后由服务器进程执行该SQ ...
- 数据库 SQL语句优化
温馨提示:本篇内容均来自网上,本人只做了稍微处理,未进行细致研究,仅当做以后不备之需,如若你喜欢可尽情转走. 一.问题的提出 在应用系统开发初期,由于开发数据库数据比较少,对于查询SQL语句,复杂视图 ...
- Sql Server中如何快速修正SQL 语句错误
本文将和大家讨论一些关于找SQL 错误的问题. 现在的系统基本都是需要用到数据库的,既然用到数据库我们就要写SQL 脚本,常用的做法是现在Microsoft Sql Server Management ...
随机推荐
- Struts2学习笔记 - Part.01
1.关于Struts2中的struts.xml文件中action设置 <!-- 它是一个通用action,此处的*表明它可以处理任意的请求--> <action name=" ...
- 三维点集拟合:平面拟合、RANSAC、ICP算法
ACM算法分类:http://www.kuqin.com/algorithm/20080229/4071.html 一: 拟合一个平面:使用SVD分解,代码里面去找吧 空间平面方程的一般表达式为: A ...
- 巧用Ajax的beforeSend提高用户体验
jQuery是经常使用的一个开源js框架,其中的$.ajax请求中有一个beforeSend方法,用于在向服务器发送请求前执行一些动作. $.ajax({ beforeSend:function(){ ...
- 一文带您了解5G的价值与应用
一文带您了解5G的价值与应用 5G最有趣的一点是:大多数产品都是先有明确应用场景而后千呼万唤始出来.而5G则不同,即将到来的5G不仅再一次印证了科学技术是第一生产力还给不少用户带来了迷茫——我们为什么 ...
- windows 端口号占用和解决方法
https://blog.csdn.net/qq_39657909/article/details/80378983
- 如何添加删除子网卡eth0:1(linux案例)
这种方法实现了单网卡多IP,我的系统是centos7的,如何添加删除子网卡IP详细请看下面操作例子 添加子网卡IP:ifconfig ens3:1 192.168.0.100/24 ...
- Linux 内核链表 list.h 的使用
Linux 内核链表 list.h 的使用 C 语言本身并不自带集合(Collection)工具,当我们需要把结构体(struct)实例串联起来时,就需要在结构体内声明指向下一实例的指针,构成所谓的& ...
- BZOJ 1367 [Baltic2004]sequence (可并堆)
题面:BZOJ传送门 题目大意:给你一个序列$a$,让你构造一个递增序列$b$,使得$\sum |a_{i}-b_{i}|$最小,$a_{i},b_{i}$均为整数 神仙题.. 我们先考虑b不递减的情 ...
- SendKeys发送组合键
使用: using System.Windows.Forms;//添加命名空间引用 { SendKeys.SendWait("{DOWN}"); ppt.ppt_sendkey(& ...
- Linux下常用函数-字符串函数
inux下常用函数-字符串函数 atof(将字符串转换成浮点型数) 相关函数 atoi,atol,strtod,strtol,strtoul 表头文件 #include <stdlib ...