2
DELIMITER $$

USE `employee`$$

DROP PROCEDURE IF EXISTS `selectemployeebyids`$$

CREATE DEFINER=`root`@`localhost` PROCEDURE `selectemployeebyids`(IN empid VARCHAR(100))
BEGIN
    SELECT empname,salary,department from emp where empid IN (empid) ORDER BY empid;
    END$$

DELIMITER ;

谁能帮帮我吗

带着敬意

文殊K

4

2 回答 2

2

在尝试了很多之后,我发现而不是IN()FIND_IN_SET()为我工作。

DELIMITER $$

USE `employee`$$

DROP PROCEDURE IF EXISTS `selectemployeebyids`$$

CREATE DEFINER=`root`@`localhost` PROCEDURE `selectemployeebyids`(IN empid VARCHAR(100))
BEGIN
    SELECT empname,salary,department from emp where empid FIND_IN_SET(empid) ORDER BY empid;
    END$$

DELIMITER ;
于 2012-09-11T06:37:04.243 回答
0

试试这个

DELIMITER $$ 

USE `employee`$$ 

DROP PROCEDURE IF EXISTS `selectemployeebyids`$$ 

CREATE DEFINER=`root`@`localhost` PROCEDURE `selectemployeebyids`(IN empid_in VARCHAR(100)) 
BEGIN 
    SELECT empname,salary,department from emp 
        where concat(',',empid_in,',') like concat('%,'cast  (empid as varchar(10)),',%')
        ORDER BY empid; 
   END$$ 


 DELIMITER ; 
于 2012-07-23T08:07:58.393 回答