在程序中运行sql报错,
ERROR 1067 (42000): 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 'CREATE TEMPORARY TABLE tmp_table
SELECT acc.accId, acc.accName, '2010-06-10' as tmpDate FROM '
sql语句如下:
DROP TABLE IF EXISTS tmp_table;
CREATE TEMPORARY TABLE tmp_table
SELECT acc.accId, acc.accName, '2010-06-10' as tmpDate FROM tbl_account acc;
insert into tmp_table SELECT acc.accId, acc.accName, '2010-06-11' as tmpDate FROM tbl_account acc;
insert into tmp_table SELECT acc.accId, acc.accName, '2010-06-12' as tmpDate FROM tbl_account acc;
select tmp.accName,att.seqId,att.attendanceType,att.beginDateTime,att.comment
from tmp_table tmp left join tbl_attendance att
on tmp.accId = att.accId
and tmp.tmpDate = str_to_date(att.beginDateTime, '%Y-%m-%d')
and str_to_date(att.beginDateTime, '%Y-%m-%d') >= '2010-06-10'
and str_to_date(att.beginDateTime, '%Y-%m-%d') <= '2010-06-12'
where 1=1;
DROP TABLE tmp_table;
这段sql在MySQL中运行没问题,但是放到程序中运行就报异常,目前程序是基于struts2 + spring + hibernate,请大家指点一下,谢谢
2010年6月22日 15:39