How to make the IN operator normally perceive the data contained in the @ids variable?

 SELECT @ids:= 63,62,12,243,237; SELECT * FROM talbe_name WHERE id IN (@ids); 
  • I tested this code - it works and works as expected. What do you mean by "normally perceived"? - KoVadim

1 answer 1

Is the output of the command SELECT @ids:= 63,62,12,243,237; did not make you think and did not cause the desire to display the resulting variable on the screen?
And even a non-working request did not cause a desire to display a variable on the screen?

In case of any problems with the code, the programmer must check the contents of all variables.

For the current problem setting, the numbers must be enclosed in quotes, and the IN replaced by FIND_IN_SET() .

But most likely the original problem is solved in a completely different way, and for this you need to know where it came from, but this will be a separate question.

  • SELECT @ ids = '63, 62,12,243,237 ', * FROM talbe_name WHERE FIND_IN_SET (id, @ids); - romeo
  • Thank you for what you need! - zsiteru