MySQL中的$符號有許多用途。下面將介紹一些常見的用途。
1. 字符串拼接 SELECT CONCAT('Hello',' ','World','!'); ->Hello World! 2. 變量 SET @num = 1; SELECT @num; ->1 3. 用戶變量 SET @sum = 20; SELECT @sum := @sum + 10 as sum, @sum as total_sum; ->sum: 30, total_sum: 30 4. 參數 CREATE PROCEDURE demo(IN id INT, OUT name VARCHAR(20)) BEGIN SELECT CONCAT('Welcome, ', name) INTO name FROM users WHERE id = id; END; CALL demo(1, @name); SELECT @name; ->Welcome, Jack 5. 環境變量 SELECT @@global.max_connections, @@session.max_connections;
上一篇mysql % [
下一篇mysql 集群部署