Home > Software design >  MySql set user variable yields error if executed in conjunction with second query
MySql set user variable yields error if executed in conjunction with second query

Time:03-04

I'm trying to use a simple user variable in MySql but I keep hitting an error condition on line 1:

SET @states = "('Alaska','Hawaii','Texas')";
select * from users where location in @states;

If I run line 1 by itself, it succeeds. But if I execute the two queries together, then it complains of an error in line 1 near @states.

  • Related