How can I insert more than 1 row into a mysql table

Posted on 2009-02-17
Last Modified: 2012-05-06
Hi I have 2 mysql tables  - (no relations defined )

One table  action_def has a column called tasks.
Another table transactions has  a column called task.

I would like to add all the distinct tasks in table transactions to the tasks in action_def.
I tried an insert statement (below) to no avail as subquery returns more than one row.
I include code as it may help explain what I am trying to do although it is clearly incorrect.
INSERT INTO action_def (task) 



from transactions))

Open in new window

Question by:j-b-t
    1 Comment
    LVL 42

    Accepted Solution

    INSERT INTO action_def (task)
     SELECT tasks from transactions group by tasks

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    A lot of articles have been written on splitting mysqldump and grabbing the required tables. A long while back, when Shlomi ( had suggested a “sed” way, I actually shell …
    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…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    759 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

    14 Experts available now in Live!

    Get 1:1 Help Now