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语句错误的更多相关文章

  1. 用PowerDesign反向生成数据库Sql语句问题

            在用Pd15反向生成数据库时,生成的Sql语句在Sql Server Manager Studio里面报错,根本就执行不了.数据库用的是Sql Server 2008 R2.经过一番修 ...

  2. 学生选课数据库SQL语句45道练习题整理及mysql常用函数(20161019)

    学生选课数据库SQL语句45道练习题: 一.            设有一数据库,包括四个表:学生表(Student).课程表(Course).成绩表(Score)以及教师信息表(Teacher).四 ...

  3. 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 ...

  4. MySQL 数据库SQL语句——高阶版本2

    MySQL 数据库SQL语句--高阶版本2 实验准备 数据库表配置: mysql -uroot -p show databases; create database train_ticket; use ...

  5. MySQL 数据库SQL语句——高阶版本1

    MySQL 数据库SQL语句--高阶版本 实验准备,数据表配置 mysql -uroot -p show databases; create database train_ticket; use tr ...

  6. 数据库添加数据II及SQL语句错误

    前些时候,写的代码(数据库添加数据I),往数据库添加数据都是很基本的一条一条地添加.但是平常用于测试时,总不可能一条一条地添加测试数据吧,然后我就尝试着一次性添加几百上千条,但是再次操作的时候,就出问 ...

  7. ORACLE数据库SQL语句的执行过程

    SQL语句在数据库中处理过程是怎样的呢?执行顺序呢?在回答这个问题前,我们先来回顾一下:在ORACLE数据库系统架构下,SQL语句由用户进程产生,然后传到相对应的服务端进程,之后由服务器进程执行该SQ ...

  8. 数据库 SQL语句优化

    温馨提示:本篇内容均来自网上,本人只做了稍微处理,未进行细致研究,仅当做以后不备之需,如若你喜欢可尽情转走. 一.问题的提出 在应用系统开发初期,由于开发数据库数据比较少,对于查询SQL语句,复杂视图 ...

  9. Sql Server中如何快速修正SQL 语句错误

    本文将和大家讨论一些关于找SQL 错误的问题. 现在的系统基本都是需要用到数据库的,既然用到数据库我们就要写SQL 脚本,常用的做法是现在Microsoft Sql Server Management ...

随机推荐

  1. pwiz, a model generator

    文档链接 pwiz is a little script that ships with peewee and is capable of introspecting an existing data ...

  2. Xcode8 NSLog打印json不完整的解决方案

    解决方案:自定义宏,通过fprintf函数打印log,完美解决! #ifdef DEBUG #define NSLog(FORMAT, ...) fprintf(stderr, "%s:%z ...

  3. 杭电2054 WA

    #include<stdio.h> #include<string.h> ],b[]; int main() { ,len2=,i; ; scanf("%s" ...

  4. ArcGIS Javascript API 加载高德在线地图扩展

    利用ArcGIS JavaScript API加载高德在线地图的扩展 /** * Created by WanderGIS on 2015/7/15. */ define(["dojo/_b ...

  5. input输入值限制

    限制输入框只能输入数字并且保留两位小数 <input type= "text" onkeyup="var p2 = parseFloat(value).toFixe ...

  6. 文字横向滚动marquee

    <div style="width:200px; height:300px"> <marquee behavior="scroll" cont ...

  7. mysql-创建用户报错ERROR 1396 (HY000): Operation CREATE USER failed for 'XXXX'@'XXXX'(转载)

    创建用户: create user ‘test’@’%’ identified by ‘test’; 显示ERROR 1396 (HY000): Operation CREATE USER faile ...

  8. 取/etc/password文件最后一个单词的最后一个字符

    三种方法都可以 [root@localhost ~]# sed -n "1,5 s#.*\(.\)#\1#p" /etc/passwd [root@localhost ~]# se ...

  9. element table 组件内容换行方案

    element table 组件内容换行方案 white-space的值: normal 默认.空白会被浏览器忽略.pre 空白会被浏览器保留.其行为方式类似 HTML 中的<pre> 标 ...

  10. Codeforces Round #468 (Div. 2, based on Technocup 2018 Final Round)A. Friends Meeting

    Two friends are on the coordinate axis Ox in points with integer coordinates. One of them is in the ...