1

For the following statement:

INSERT INTO main_app_provider (provider) 
VALUES ((SELECT distinct(provider) FROM raw_financials));

I get a "subquery returns more than one row".

It seems the above is trying to do an INSERT into a single row. How would I load this into a table for multiple rows (i.e., so each provider is inserted into a new row)?

2
  • it IS trying to do an insert into a single row.. Commented Jan 23, 2012 at 19:31
  • For reference, the MySQL manual shows the proper syntax for INSERT ... SELECT and all other statements MySQL supports. Commented Jan 23, 2012 at 19:32

3 Answers 3

5

Remove the VALUES keyword. The parentheses around the SELECT are not strictly needed either.

INSERT INTO main_app_provider (provider) SELECT distinct provider FROM raw_financials;

See the MySQL INSERT syntax reference for full details.

Sign up to request clarification or add additional context in comments.

Comments

1

Right syntax is without values:

INSERT INTO main_app_provider (provider) 
  SELECT distinct(provider) 
  FROM raw_financials

Comments

0

Try this.

INSERT INTO main_app_provider (provider) SELECT distinct(provider) as Provider FROM raw_financials;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.