-2

Here's my input data: https://i.stack.imgur.com/K3WrM.png

If user input data like:

> CALL Hobbies_Input('football')
> 
> CALL Hobbies_Input('Badminton')
> 
> CALL Hobbies_Input('Cricket')

They should get their respective outputs.

I tried to do this, Here's my stored procedure:

DELIMITER &&
CREATE PROCEDURE Hobbies_Input (IN var1 VARCHAR(50))
BEGIN  
    SELECT * FROM sample_data WHERE FIND_IN_SET(Hobbies, var1);
END &&
DELIMITER;

It's working for my first case[CALL Hobbies_Input('football')] But its showing zero rows for my second and third case, how can i rectify this?

Jatin
  • 11
  • 4
  • Find _in Set can't find data in a delimited column so read up on https://stackoverflow.com/questions/3653462/is-storing-a-delimited-list-in-a-database-column-really-that-bad and normalize your table – nbk Oct 31 '21 at 10:59

1 Answers1

0

does this work?

DELIMITER &&
CREATE PROCEDURE Hobbies_Input (IN var1 VARCHAR(50))
BEGIN  
    SELECT * FROM sample_data WHERE FIND_IN_SET(REPLACE(Hobbies, ';', ','), var1);
END &&
DELIMITER;
fmansour
  • 555
  • 3
  • 17