SQL Insert into Select Query Example

Guys you are trying to insert data from one of your existing table to another existing table or same table in mysql you can use SQL Insert into Select Query. The following query will explain

INSERT INTO users (user_id,username,email,password)
SELECT user_id,username,email,password FROM users;

You can add where clause too,

INSERT INTO users (user_id,username,email,password)
SELECT user_id,username,email,password FROM users
Where user_id <= 5;

 

Comments

comments

phpexpertise

I’m Blogger and Programming Blog, Tutorials, PHP, MySQL, jQuery, Laravel, Wordpress and Codeigniter