Java 带积垢的限值1
我只想得到最后插入的Java 带积垢的限值1,java,mysql,spring,limit,crud,Java,Mysql,Spring,Limit,Crud,我只想得到最后插入的MyTable的一个结果。 所以我把LIMIT 1或LIMIT 0,1改为两个结果。 它抛出一个异常。 我该怎么办? 我在mysql数据库上使用了org.springframework.data.repository.crudepository @Query("select t from MyTable t " + " where " + " t.date <= :date " + " order by t.d
MyTable
的一个结果。
所以我把LIMIT 1
或LIMIT 0,1
改为两个结果。
它抛出一个异常。
我该怎么办?
我在mysql数据库上使用了org.springframework.data.repository.crudepository
@Query("select t from MyTable t " +
" where " +
" t.date <= :date " +
" order by t.date desc " +
" LIMIT 1 ")
MyTable findOnlyTheLast(
@Param("date") String date);
@Query(“从MyTable t中选择t”+
“哪里”+
“t.date尝试在where子句中添加一个条件,以选择满足条件的最大日期
@Query("select t from MyTable t " +
" where " +
" t.date <= :date " +
" and t.date = (select max(tt.date) from MyTable tt where tt.date <= :date)" +
" order by t.date desc")
@Query(“从MyTable t中选择t”+
“哪里”+
“t.date尝试在where子句中添加一个条件,以选择满足条件的最大日期
@Query("select t from MyTable t " +
" where " +
" t.date <= :date " +
" and t.date = (select max(tt.date) from MyTable tt where tt.date <= :date)" +
" order by t.date desc")
@Query(“从MyTable t中选择t”+
“哪里”+
“t.日期