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我在这里使用=运算符,但它只比较值。 我也试过:=运算符,但它显示以下错误:
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
请帮我解决这个问题。
答案 0 :(得分:0)
尝试更改:
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