I have table emloyee with following data.
Id Name Country
1 John USA
2 Smith USA
3 Jack IND
4 Lory UK
5 Miller USA
I want to get result by calling stored procedure like this
call getEmployeeDetailsByCountry('IND,UK');
Result:
Id Name Country
3 Jack IND
4 Lory UK
My Procedure is
select * from employee
where if( (LOCATE(',','IND,USD')>0),
Country in (concat('\'',REPLACE('IND,USD', ',', '\',\''),'\''))
, Country in ('IND,USD'));
Here it replaces 'IND,USD' to 'IND','USD'. But result is no rows.... Can anyone help me to find..... thank you
Use FIND_IN_SET instead of IN
SELECT *
FROM product
WHERE FIND_IN_SET(country, 'IND,USD');
Try this i think this will solve your problem
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With