开发者

Mysql query throwing error

I am getting a :

You have an error in your sql syntax; check the manual that correspondes to....

here is my query. I do MSSQL, I am new to mysql .. Please help

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


Unless this is part of a stored procedure or function or trigger, this simply isn't a valid form for a MySQL query. You can't just write freeform logic into a single query with MySQL.

You probably want to write an INSERT INTO...ON DUPLICATE KEY UPDATE query.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜