Skip to content
Advertisement

How to execute a raw sql query with multiple statement with laravel

Is there anyway I can execute a query with multiple statement like the one below, using laravel framework. I have tried using DB::statement but returned a sql syntax error, but when I execute the same query on phpmyadmin I works, its so frustrating. Please help me.

EG

JavaScript

Advertisement

Answer

DB::unprepared() should do the trick , laravel prepare and do some stuff for sql queries .
But instead you can use absolutely raw ones using DB::unprepared .

EG

JavaScript

It will execute your whole SQL query whether it is single/multiple statements .

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement