Inserting records from a SELECT statement (MySQL)
September 9, 2008
I often forget even simple syntax that makes MySQL operation easy. I’m just adding this basically for personal reference.
Using INSERT statement combined with the SELECT statement you could actually add records from one table to another table. Adding a WHERE clause could enable you to filter the records to copy. Below is the syntax.
INSERT INTO table_destination SELECT * FROM table_source [WHERE condition];
However this generic statement only works if the two tables have the same order of columns and has compatible data types. If that is not the case you would need to specify the columns like the following syntax:
INSERT INTO table_destination (column_1, column_2, column_3) SELECT column_1, column_2, column_3 FROM table_source [WHERE condition];
Filed under: MySQL |
Comments (4)
Related Links:

Pillspot.org. Canadian Health&Care.No prescription online pharmacy.Special Internet Prices(up to 40% off average US price).Pillspot.org. Herbal-supplements@buy.online” rel=”nofollow”>.< /a …
Categories: Stop SmokingWeight Loss.Antibiotics.Mental Health/Epilepsy.Anti-allergic/Asthma.Pain Relief.Womens Health.Vitamins/Herbal Supplements.Cholesterol.Blood Pressure/Heart.Stomach.Antiviral.Skin Care.Anxiety/Sleep Aid.Eye Care.Antidepressan…
Buy:Prednisolone.Lumigan.Mega Hoodia.Synthroid.Zovirax.100% Pure Okinawan Coral Calcium.Valtrex.Accutane.Prevacid.Petcam (Metacam) Oral Suspension.Retin-A.Arimidex.Nexium.Actos.Zyban.Human Growth Hormone….
Buy:Wellbutrin SR.Ventolin.Lasix.Benicar.Zocor.Female Pink Viagra.Lipitor.Amoxicillin.Zetia.Acomplia.Lipothin.Cozaar.Seroquel.Aricept.Advair.SleepWell.Nymphomax.Female Cialis.Prozac.Buspar….
Buy:Aricept.Seroquel.Nymphomax.Lasix.Lipitor.Zocor.Advair.Cozaar.Acomplia.Amoxicillin.Wellbutrin SR.Prozac.SleepWell.Female Pink Viagra.Lipothin.Zetia.Female Cialis.Buspar.Benicar.Ventolin….