-2
我想根據參數從數據庫中的一個表中選擇數據。 這是我所做的。MySql Select Case從表中選擇數據
DELIMITER $$
CREATE PROCEDURE `myDB`.`Temp`(
IN ID INT(11)
)
BEGIN
SELECT CASE
WHEN ID IN(1,2) THEN
SELECT * FROM table1;
WHEN ID IN(3,4) THEN
SELECT * FROM table2;
END CASE;
END$$
DELIMITER ;
但是。我得到錯誤:
Error Code : 1064
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 'SELECT * FROM table1;
WHEN ID IN(3,4) THEN
SELECT * FROM table2;
END' at line 7