Use mysql SET variables in db_query
There are 2 points here.

SET @x := 5,SET @y := 6, SELECT * from mytable" should be "SET @x := 5,SET @y := 6; SELECT * from mytable


as

SET @x := 5,SET @y := 6;" and "SELECT * from mytable


are 2 separate MySQL statements.

You can not execute multiple statements together using db_query(). Since the PHP functions mysql_query() and mysqli_query() can only execute one SQL statement, the db_query() wrapper can also only execute one SQL statement.

What you can do here is, divide that into two part and run it.

db_query('SET @x := 5,SET @y := 6;')-&gt;execute();
db_query('SELECT * from mytable')-&gt;fetchAll();