How to Execute mysql Query in Laravel?

By Hardik Savani | May 2, 2016 | Category : Laravel

Sometimes, we require to run directly mysql query on Laravel for example if you need to copy one table to other table using mysql query. I also need in one project and that's why i am fetching problem. But you can use sql query on laravel using db statement in bellow example you can learn how to run.



INSERT INTO `posts` (repost_of_id,token_id,post_details,user)

SELECT id,token_id,post_details,".$loginUserId."

FROM `posts` where id = ".$postId."


Hardik Savani
My name is Hardik Savani. I'm a full-stack developer, entrepreneur and owner of Aatman Infotech. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.
Follow Me: Github Twitter
***Do you want me hire for your Project Work? Then Contact US.