문제

What's the difference between DECLARE and SET using SQL (or more specifically MySQL)?

Both can set variables it seems. I have read the MySQL docs and I did not understand the difference between the two.

도움이 되었습니까?

해결책

DECLARE does not initialize the variable. When you declare it you declare the variable name, the type, and a default value, which could be an expression.

SET is for initializing the variable you declared previously, and you cannot SET the variable until you DECLARE it.

다른 팁

DECLARE defines the variable type and SET initializes the variable.

DECLARE @Var1 INT;
DECLARE @Var2 INT;
SET @Var1 = 1;
SET @Var2 = 2;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top