-2

我收到此语句的语法错误。知道为什么吗?

我唯一的猜测是会话记录可能已从选择中锁定,因此无法在同一事务中删除。但这似乎不会导致语法错误。

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';

有任何想法吗?

4

1 回答 1

0

在 insert into ... select .. 语句中不能有括号。

insert into sessions_history 
      select * 
      from sessions 
      where session_id = 'jjmn6hmuor8mqa2j1vb4gdpno0';
于 2012-12-05T20:08:46.507 回答