在写代码时候写了
update tbl_lock_use set user_name=#{userName},nick_name=#{nickName},location=#{location},status=#{status},update_by = #{updateUser}, date_update = sysdate() where date_update=(select a.date_update from(select max(date_update)from tbl_lock_use where sn=#{sn})
但是报错
You can’t specify target table ‘A’ for update in FROM clause
意思是:你不能在同一个sql语句中先查询某些值,在修改这个表。
解决办法:select的结果再通过一个中间表select多一次。
DELETE
FROM
table_score_one
WHERE
id NOT IN (
SELECT
a.min_id
FROM
(
SELECT
min(id) AS min_id
FROM
table_score_one
GROUP BY
student_no,
class_no,
class_name,
score
) a
);