Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By ahmed_h on
How can i use mysql SET variables while using my PDO queries?
db_query('SET @x := 5,SET @y := 6, SELECT * from mytable')->fetchAll();
I have tried this and many variations of this statement with and without ':' etc, but it doesn't work.
Comments
Hi ahmed_h,
Hi ahmed_h,
There are 2 points here.
What you can do here is, divide that into two part and run it.
db_query('SET @x := 5,SET @y := 6;')->execute();
db_query('SELECT * from mytable')->fetchAll();