Tuesday, 15 September 2015

mysql - Copy rows from one table onto another using INSERT query -


I have a table with 158 columns and 22,000 rows and I have another empty table, where I dynamically The SELECT query coming from WHERE user will look something like this:

SELECT * myfrist_tables WHERE suic_att & gt; = 5 and gender = 'm'

This gives me around 9,000 records (say) I want to put these records in another table (just this filtered data). Is this possible? Can anyone tell me what the INSERT query looks like, and I need to create another table with all those 158 clients, or dynamically create all 158 columns in the INSERT query? Also, can I use it in a scene or is it necessary to have a table? thank you in advanced!

It looks as if you want to run SELECT above the statement And the INSERT result does not exist in a new table that does not exist. If yes, then it should work: YourNewTable in MyCreate_tables WHERE suic_att & gt; = 5 and gender = 'M'

YourNewTable already exists, you will need to run INSERT:

  In its new selection Include * mygrist_tables from WHERE suic_att & gt; = 5 and gender = 'M'   

Alternatively, you may need to specify the column because they are not identical.

edit - Rereading comments and realizing DB is MySQL, to create a new table with a SQL statement, your Should use:

  select your new table * from mygrist_tables WHERE suic_att & gt; = 5 and gender = 'm';   



No comments:

Post a Comment