0

I am tryong to set a constant list of the uids of the dev team of a project so I can later in my MySQL script exclude them from queries with something like .. where user not in @dev_team_ids .. but I am getting this error:

mysql> set @dev_team_ids = (1,2,4);
ERROR 1241 (21000): Operand should contain 1 column(s)

Is there a way to get around this?

1
  • can you post your query and constant values code ? so I can look into ? Commented Jan 12, 2015 at 7:15

1 Answer 1

1

MySQL doesn't have arrays in the usual sense. You can use a temporary lookup table containing your values, or you can use a string with comma-delimited values, in conjunction with FIND_IN_SET:

set @dev_team_ids = '1,2,4';

.. where not FIND_IN_SET(user, @dev_team_ids) ..
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.