how can I use SET @variable with createCommand

I’m trying to set a mysql variable with create command and run a query afterwards that uses the variable. It doesn’t work. The variable is always not set.