Skip to content
Advertisement

How to use parameters command with IN operator in mysql and vb.net

I need to use IN operator in WHERE clause so I tried the next code with my SQL statement but it gives me the record for the first number only:

I tried also:

but didn’t give me results, how can I solve that problem, please note that I don’t know the number of the codes so maybe it will be (1,2,3,4,5) or less or more.

Advertisement

Answer

It seems like you want to check if a value belongs to a comma-separated list. You can’t do that with IN, which expects a list of values, not a single string of values.

A generic solution uses string functions:

In MySQL, however, you can use handy string function find_in_set():

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement