我在这个语句中遇到语法错误。知道为什么吗?
我唯一的猜测是,会话记录可能已从select中锁定,因此无法在同一事务中删除。但这似乎不会导致语法错误。
insert into sessions_history
select *
from sessions
where session_id = 'jjmn6hmuor8mqa2j1vb4gdpno0';
delete from sessions
where session_id = 'jjmn6hmuor8mqa2j1vb4gdpno0';
这是错误:
错误号码:1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'delete from sessions where session_id = 'vk744qiebkfr0el7tesi65us04'' at line 1
insert into sessions_history select * from sessions where session_id = 'vk744qiebkfr0el7tesi65us04'; delete from sessions where session_id = 'vk744qiebkfr0el7tesi65us04';
有什么想法吗?
答案 0 :(得分:0)
插入到... select ..语句中不能有括号。
insert into sessions_history
select *
from sessions
where session_id = 'jjmn6hmuor8mqa2j1vb4gdpno0';