0

I am trying to create a calculation logic using MySQL tables. Data from two table is processed using a stored procedure and a set of values is generated. These values are part of a column of output table. I have to run different procedure to generate output for each column in output table

Now if I create insert query for each row it will have large number of inserts for each column. Can I insert a set of values into a table column in one go? assuming other columns can be NULL.

1
  • yes e.g. insert into tabA (name,roll) values ('aaa',12) ; and assuming that tabA has one more column school , school will have the value as NULL Commented May 3, 2012 at 12:44

2 Answers 2

2
INSERT INTO tableName(columnName)
VALUES ('baz'),('foo'),('bar'),('baz'),('baz'),('baz'),('baz');

etc as u like..

See this: Bulk insert into table with one single query

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

Comments

0

The insert can be done for one column rest can be NULL if remaining columns are nullable.

But next time for the remaining columns the Insert will not work for the existing rows. If You want to update the existing rows then you need to fire the update query.

Assuming col1 and col2 are nullable

If you want to insert in col1 keeping col2 null insert will work If you want to insert in col2 keeping col1 null insert will work

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.