android.database.sqlite.SQLiteException: near "&": syntax error (code 1 SQLITE_ERROR): , while compiling: SELECT * FROM drafts WHERE book_id1=? && title like ?
时间: 2023-06-25 07:02:58 浏览: 88
这个错误通常是由 SQL 语法错误引起的。在你的 SQL 语句中,使用了 `&&` 运算符,但是 SQLite 不支持这个运算符,正确的运算符是 `AND`。
你需要将你的 SQL 语句修改为:
```
SELECT * FROM drafts WHERE book_id1=? AND title like ?
```
这样就可以避免这个错误了。
相关问题
android.database.sqlite.SQLiteException: no such table: rundata (code 1 SQLITE_ERROR): , while compiling:
This error indicates that the SQLite database you are trying to query does not contain a table named "rundata". This could be due to a few reasons:
1. The table has not been created yet: Make sure you have executed the SQL query to create the "rundata" table before trying to query it.
2. The table was deleted: If you or your application deleted the "rundata" table, you will need to recreate it before querying it again.
3. The table was renamed: If the "rundata" table was renamed, make sure you are querying the correct table name.
4. The table is in a different database: If the "rundata" table is in a different database than the one you are currently querying, you will need to connect to that database first before querying the table.
You can check if the "rundata" table exists in your database by running the following query:
```
SELECT name FROM sqlite_master WHERE type='table' AND name='rundata';
```
This will return the name of the table if it exists in your database.
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.mywriteproject/com.example.mywriteproject.setActivity}: android.database.sqlite.SQLiteException: near "set": syntax error (code 1 SQLITE_ERROR): , while compiling: SELECT * FROM set WHERE book_id=?
这个异常是由于 SQLite 查询语句中使用了保留关键字 "set",导致语法错误。在 SQL 中,"set" 是用于更新数据的关键字,如果在查询语句中使用会引发异常。
解决方法是将查询语句中的 "set" 关键字改为其他名称或者加上反引号(`)进行转义,如下所示:
```java
SELECT * FROM `set` WHERE book_id=?
```
这样就可以避免因为关键字冲突而导致的语法错误。
相关推荐
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)