IN()不在mysql存储过程中工作

时间:2022-04-17 16:05:26
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 ;

can anyone please help me

谁能帮帮我吗

With Regards

Manju K

2 个解决方案

#1


2  

After trying lot i find instead of IN(), FIND_IN_SET() works for me.

在尝试了很多我找到而不是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 ;

#2


0  

Try this

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 ; 

#1


2  

After trying lot i find instead of IN(), FIND_IN_SET() works for me.

在尝试了很多我找到而不是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 ;

#2


0  

Try this

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 ;