zoukankan      html  css  js  c++  java
  • 数据库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 1): , while compiling: select * from wenjian  where 1=1  and  duanhao=01端,(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)
    Caused by: android.database.sqlite.SQLiteException: no such column: LOG(Sqlite code 1): , while compiling: select * from wenjian  where 1=1  and  gongneng=LOG,(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)

    最后解决:

    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个小时。

    学习……

    今天多一点积累,明天少一分烦恼
  • 相关阅读:
    git版本回退:git reset --hard 版本号
    cheerio中文文档
    疫情实时大数据报告(利用nodejs)
    Package.json 属性说明
    11 个Chrome骚技巧让你为所欲为
    vue刷新页面空白分两种情况
    修改i输入框中placeholder的样式
    input输入框显示不全是用省略号...代替
    PC端适应屏幕分辨率
    CSS设置滚动条样式
  • 原文地址:https://www.cnblogs.com/galibujianbusana/p/6387778.html
Copyright © 2011-2022 走看看