我得到了:
你的sql语法有错误;检查对应的手册....
这是我的查询。我做MSSQL,我是mysql的新手..请帮忙
IF EXISTS (SELECT * FROM TIMESHEET WHERE EMPLOYEEID = '1' AND PERIODENDINGDATE = '2011-01-30')
UPDATE TIMESHEET SET STATUSCODE = 'P', PERIODENDINGDATE = '2011-01-30', DEPARTMENTCODE = 'IT'
MINUTESMON = '200', MINUTESTUE= '200', MINUTESWED='200', MINUTESTHU='200'
MINUTESFRI='200', MINUTESSAT='200', MINUTESSUN='200'
ELSE
INSERT INTO TIMESHEET (EMPLOYEEID, STATUSCODE, PERIODENDINGDATE, DEPARTMENTCODE, MINUTESMON, MINUTESTUE,
MINUTESWED, MINUTEDTHU, MINUTESFRI, MINUTESSAT, MINUTESSUN)
VALUES ('1','P','2011-01-30','IT','200','200','200','200','200','200','200')
答案 0 :(得分:1)
除非这是存储过程或函数或触发器的一部分,否则这不是MySQL查询的有效形式。您不能只使用MySQL将自由形式逻辑写入单个查询中。
您可能想要撰写INSERT INTO...ON DUPLICATE KEY UPDATE
查询。