if(select * from dailytotal where cusid ='1'and date='2015-06-11')is null then Insert into mess.dailytotal (cusid,name,date,morning,afternoon,evening,night) values('1','vignesh','2015-06-11',0,30,0,0);
else
update mess.dailytotal set afternoon='30',evening='0',night='0' where cusid='1' and date='2015-06-11';
end if;
it has an error like please check give a perfect answer?
if( SELECT *
FROM dailytotal
WHERE cusid = '1'
AND date = '2015-06-11' ) IS NULL
THEN INSERT INTO mess.dailytotal(
cusid,
name,
date,
morning,
afternoon,
evening,
night
)
VALUES (
'1', 'vignesh', '2015-06-11', 0, 30, 0, 0
);
MySQL said: Documentation
#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 'if(select * from dailytotal where cusid ='1'and date='2015-06-11')is null then I' at line 1
此错误是否存在任何版本问题?
答案 0 :(得分:0)
你做错了,mysql中正确的语法就像:
if(condition, if condition satisfied, if not satisfied)