gpt4 book ai didi

php - mysql存储过程中如何使用赋值运算符

转载 作者:行者123 更新时间:2023-11-30 23:16:31 26 4
gpt4 key购买 nike

    DECLARE sp_ApplicationId char(38);
SET sp_ApplicationId = UUID();

IF(EXISTS(SELECT sp_ApplicationId = ApplicationId FROM aspnet_Applications WHERE LOWER(sp_ApplicationName) = LoweredApplicationName)) THEN

SELECT 'Application Name Already Exist';

我想在满足条件时将应用程序 ID 分配给 sp_ApplicationId 我使用了 = 运算符,但它只比较值。 我也试过 := operator 但它显示以下错误:

 Error code 1064, SQL state 42000: 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 ':= ApplicationId FROM aspnet_Applications WHERE LOWER(sp_ApplicationName) = Lowe' at line 14 

请帮我解决这个问题。

最佳答案

尝试改变:

SELECT sp_ApplicationId = ApplicationId FROM aspnet_Applications WHERE       LOWER(sp_ApplicationName) = LoweredApplicationName

到:

SELECT 1 FROM aspnet_Applications WHERE       LOWER(sp_ApplicationName) = LoweredApplicationName

更新 如果您尝试将 ApplicationId 的值分配给 sp_ApplicationId 变量,您可以尝试:

SELECT ApplicationId INTO sp_ApplicationId FROM aspnet_Applications WHERE       LOWER(sp_ApplicationName) = LoweredApplicationName

关于php - mysql存储过程中如何使用赋值运算符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17464183/

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