gpt4 book ai didi

mysql - 我的 SQL 代码有什么问题?在最后一行出现错误

转载 作者:行者123 更新时间:2023-11-29 01:54:15 25 4
gpt4 key购买 nike

我正在尝试创建一个 MySQL 程序来计算税收。但是它说我在第 9 行有一个涉及 ')' 标记的错误。知道如何解决吗?错误信息是:

#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 'SELECT ((pSalary - taxExempt) * taxRate) INTO taxesDue; END' at line 27 

我的代码是:

DELIMITER //

CREATE PROCEDURE calc_state_tax(
IN pSalary DECIMAL(9,2),
IN pStateCode VARCHAR(2),
IN pStatus VARCHAR(6),
OUT taxesDue DECIMAL(9,2)
)

BEGIN
DECLARE taxRate DECIMAL(7,5);
DECLARE taxExempt DECIMAL(9,2);

SELECT
s1.taxRate,
s1.exemptperfiler
INTO taxRate,taxExempt
FROM statetax s1
WHERE s1.statecode = CONCAT("'",pStateCode ,"'")
AND s1.type = CONCAT("'",pStatus,"'")
AND s1.bracket = (
SELECT MAX( s2.bracket )
FROM statetax s2
WHERE s1.statecode = s2.statecode
AND s1.type = s2.type
AND s2.bracket < pSalary )


SELECT ((pSalary - taxExempt) * taxRate) INTO taxesDue;

END; //
DELIMITER;

最佳答案

正如我的评论所述:

AND s2.bracket < pSalary ) 后缺少分号

关于mysql - 我的 SQL 代码有什么问题?在最后一行出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33534885/

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