gpt4 book ai didi

mysql - if 条件下 mysql 中的错误#1064

转载 作者:行者123 更新时间:2023-11-29 22:20:44 25 4
gpt4 key购买 nike

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

这个错误是否有版本问题?

最佳答案

你做错了,mysql中正确的语法是这样的:

 if(condition, if condition satisfied, if not satisfied)

关于mysql - if 条件下 mysql 中的错误#1064,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30749489/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com