Main Contents

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:

4 Comments

  1. BRENT June 25, 2010 @ 8:17 pm

    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…

  2. RANDALL July 16, 2010 @ 2:34 am


    PillSpot.org. Canadian Health&Care.Best quality drugs.No prescription online pharmacy.Special Internet Prices. Low price pills. Buy drugs online

    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….

  3. EARL July 21, 2010 @ 9:26 am


    MedicamentSpot.com. Canadian Health&Care.Best quality drugs.Special Internet Prices.No prescription online pharmacy. No prescription drugs. Order drugs online

    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….

  4. ARTURO July 21, 2010 @ 10:16 pm


    MedicamentSpot.com. Canadian Health&Care.Special Internet Prices.No prescription online pharmacy.Best quality drugs. Low price drugs. Buy drugs online

    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….

Leave a comment