copy values from existing table into new table

Posted on 2012-08-18
Last Modified: 2012-08-20
varchar column1
varchar volumn2

new empty
varchar column1

copy table1.column1 into table2.column1 where table1.column2 is not null
Question by:rgb192
    LVL 12

    Accepted Solution

    It sounds like you are interested in the INSERT INTO ... SELECT syntax.
    See, for instance, MySQL 5.5 documention

    INSERT INTO table2 (column1)
        SELECT table1.column1
        FROM table1 WHERE table1.column2 IS NOT NULL;
    LVL 76

    Assisted Solution

    It is rather not clear why you need this, creating a view might be a better approach to have the same info that will be continually updated.

    Author Closing Comment

    thank you

    also thanks for advice about view which I did not use yet

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Introduction In this article, I will by showing a nice little trick for MySQL similar to that of my previous EE Article for SQLite (, A SQLite Tidbit: Quick Numbers Table Generation (…
    More Fun with XML and MySQL – Parsing Delimited String with a Single SQL Statement Are you ready for another of my SQL tidbits?  Hopefully so, as in this adventure, I will be covering a topic that comes up a lot which is parsing a comma (or other…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now