Click here to Skip to main content
15,897,334 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi every one!

I am new with MySql, but I am familiar with SQL Server.
I have a problem with MySql.

I want to select records from a table and insert into a new or temporary table.
In SQL Server

select * into NewTable from ExistingTable
or select * into #TmpTable from ExistingTable

How to follow these in MySql?

Thanks!
Posted

1 solution

In MySQL, you can use SELECT into as follows:

SELECT field1, field2 INTO var1,var2 FROM table1 LIMIT 1;

This will allow us to store the selected columns directly into variables.

http://dev.mysql.com/doc/refman/5.0/en/select-into-statement.html[^]

You should create a temp table first and then use

insert into temp_table ... select * from table.. example reference:
http://www.tutorialspoint.com/mysql/mysql-temporary-tables.htm[^]
 
Share this answer
 
Comments
Bun Leap_kh 15-Jun-11 1:38am    
Thanks so much

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900