DELIMITER $$
CREATE PROCEDURE abc(IN _uid VARCHAR(15))
BEGIN
SELECT COUNT(filename)
FROM file
WHERE userid = _uid
UNION ALL
SELECT COUNT(file)
FROM fileupload
WHERE userid = _uid
END $$
DELIMITER ;
这是我的查询,因为我需要两个select语句输出
但是收到错误
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'END' at line 10
答案 0 :(得分:0)
尝试:
mysql> DELIMITER $$
mysql> CREATE PROCEDURE abc(IN _uid VARCHAR(15))
-> BEGIN
-> SELECT COUNT(filename)
-> FROM file
-> WHERE userid = _uid
-> UNION ALL
-> SELECT COUNT(file)
-> FROM fileupload
-> -- WHERE userid = _uid
-> WHERE userid = _uid;
-> END$$
Query OK, 0 rows affected (0.00 sec)
mysql> DELIMITER ;