1
    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 

请帮我解决这个问题。

4

1 回答 1

0

尝试改变:

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

至:

SELECT 1 FROM aspnet_Applications WHERE       LOWER(sp_ApplicationName) = LoweredApplicationName

更新如果您尝试将值分配ApplicationIdsp_ApplicationId变量,您可以尝试:

SELECT ApplicationId INTO sp_ApplicationId FROM aspnet_Applications WHERE       LOWER(sp_ApplicationName) = LoweredApplicationName
于 2013-07-04T07:56:32.873 回答