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. Win10 UWP Tile Generator

    图标生成器 https://marketplace.visualstudio.com/items?itemName=shenchauhan.UWPTileGenerator 备份地址: http:// ...

  2. Django 中的 csrf_token 与单元测试

    Django 中的 csrf_token 与单元测试 在<Python Web开发:测试驱动方法>一书中作者使用的 Django 版本是 1.7,而我使用的是1.9.7版(官网已经更新到1 ...

  3. Resolving Strong Reference Cycles for Closures

    You resolve a strong reference cycle between a closure and a class instance by defining a capture li ...

  4. -webkit-appearance: none; 去除浏览器默认样式

    -webkit-appearance: none;    去除浏览器默认样式

  5. Delphi中实现文件拷贝的三种方法

    1.调用API函数procedure CopyFile(FromFileName,ToFileName:string);varf1,f2:file;BeginAssignFile(f1,FromFil ...

  6. 小白学习Spark系列六:Spark调参优化

    前几节介绍了下常用的函数和常踩的坑以及如何打包程序,现在来说下如何调参优化.当我们开发完一个项目,测试完成后,就要提交到服务器上运行,但运行不稳定,老是抛出如下异常,这就很纳闷了呀,明明测试上没问题, ...

  7. Python数据分析-----数据分类

    1.常见的分类算法主要有: (1)KNN算法 (2)贝叶斯方法 (3)决策树 (4)人工神经网络 (5)支持向量机(SVM) 2.KNN算法 (1)KNN应用场景: 比方说样本中有很多零食.很多电器. ...

  8. ubuntu16.04下安装配置nodejs及npm

    官网下载ubuntu对应的二进制文件(Linux Binaries (x64)这一行) https://nodejs.org/en/download/ 解压并安装 ``` $tar zxvf node ...

  9. springboot实现mongodb上传下载

    1.上传: private static Logger log = LoggerFactory.getLogger(MongoDbFSUtil.class); private static final ...

  10. Tab 切换效果

    今天写的两个小效果都是为了测试我写的单参函数,结果还是有点成功的~~此处是不是想发表情包! Tab效果很简单,这里我就不赘述了,直接上代码: html代码: <div class="c ...