[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2009-02-17
1
Medium Priority
?
1,141 Views
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) 
 
VALUES ((SELECT DISTINCT
tasks
from transactions))

Open in new window

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

Accepted Solution

by:
dqmq earned 2000 total points
ID: 23665478
INSERT INTO action_def (task)
 SELECT tasks from transactions group by tasks
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month17 days, 23 hours left to enroll

829 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