Going crazy trying to set a variable in a query of type:
SET @idcamposexcluidos='817,803,495';
so i can then use it on a
WHERE id_campo not in (@idcamposexcluidos)
I've tried defining the variable in different formats with no luck and don't seem to find an specific example for the above:
SET @idcamposexcluidos='(817,803,495)';
...
WHERE id_campo not in @idcamposexcluidos
SET @idcamposexcluidos=817,803,495;
with no success. It either returns an error or ignores the values.
inlike that. You need seperate variables or use a dynamic SQL.FIND_IN_SETandLIKEare OK for small tables. But they do not perform well because they have to look at every row. Most languages have no simple way (if any way) to construct the much fasterIN(...)clause, which can use an index.