我想根据参数从数据库中的一张表中选择数据。这就是我所做的。
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