@Select("select * from (select * from createpost where createdAt between #{createdBegin} and #{createdEnd}) " + "limit #{start},#{end} ") HashMap<String,Object> findPage(Integer start, Integer end,Date createdBegin,Date createdEnd);报错 "\r\n### Error querying database. Cause: java.sql.SQLSyntaxErrorException: Every derived table must have its own alias\r\n### The error may exist in com/example/myhoutai/mapper/PostMapper.java (best guess)\r\n### The error may involve com.example.myhoutai.mapper.PostMapper.findCount-Inline\r\n### The error occurred while setting parameters\r\n### SQL: select count(*) from (select * from createpost where createdAt between ? and ?) limit ?,?\r\n### Cause: java.sql.SQLSyntaxErrorException: Every derived table must have its own alias\n; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: Every derived table must have its own alias",
时间: 2024-02-03 19:03:54 浏览: 193
这个错误是因为 SQL 语句中的子查询必须要有别名,你可以在子查询后面添加别名,例如:
```
select count(*) from (select * from createpost where createdAt between ? and ?) as c limit ?,?
```
这样就为子查询添加了别名 `c`,避免了出现该错误。
阅读全文
相关推荐


















