Questions tagged [multiple-insert]

Use this tag for questions about inserting multiple rows in a single statement into an SQL database.

Multiple row inserts are a feature of many SQL databases. They're a feature of the SQL-92 standard.

The most common syntax for multiple row inserts is similar to a normal INSERT INTO statement, but with multiple value groups separated by comma's

INSERT INTO MyTable(Value1, Value2)
VALUES 
    ('Value1Row1', 'Value2Row1'), 
    ('Value1Row2', 'Value2Row2'),
    ('Value1Row3', 'Value2Row3')

Alternatively, multiple row inserts can be achieved by using an INSERT INTO ... SELECT statement and UNION queries in many RDBMS.

For more information, see Wikipedia on multi-row inserts.

81 questions
0
votes
0 answers

Getting error array to string conversation

I want to insert multiple data using add button and the data of dynamically added button doesn't inserted sometimes get 0 and sometimes just no change... include 'config.php'; if(isset($_POST['submit1'])) { $bill_no =…
Keshu Odedara
  • 21
  • 1
  • 5
0
votes
1 answer

How do I run insert scripts in one service in spring, mysql

I am using Sprig 4.2xx / Mybatis/ MariaDB. I have Mybatis insert query. INSERT INTO side_att_rel …
henry kim
  • 1
  • 1
0
votes
1 answer

MYSQL and Node.js multiple record insert with where clause

I am trying to insert multiple records into MYSQL from Node.js with a WHERE clause but I keep getting a syntax error. The statement works fine until I try to add a conditional statement to it. Then I get this error: ER_PARSE_ERROR: You have an error…
0
votes
1 answer

Multiple INSERT INTO statements within one query

I have two tables: BT and ST. Here is what I hope I can accomplish: INSERT INTO BT (c1,c2,c3) values (v1,v2,v3) ST is a table with 89 rows and one column. Can and if so, how can I formulate a query so that the insert works for every one of the 89…
0
votes
1 answer

Multiple insert into database not working

I am trying to insert multiple rows into my database at once. The user can add up to 5 new rows for blood results to be inserted into the database. There is an add more button to allow them to do this. I have a loop to iterate through each entry…
P. Smith
  • 7
  • 5
0
votes
1 answer

TVP insert shows many SP:Starting and SP:Completed events in SQL Server Profiler

I am profiling an insert query that takes a temporary table as parameter, and seeing that each item being inserted counts towards a SP:Starting and SP:Completed event in SQL Server Profiler. Here is roughly the query I am doing: DECLARE @temptable…
Andrew
  • 1,355
  • 2
  • 13
  • 28
0
votes
1 answer

Trigger :Do not execute INSERT INTO when SELECT returns no result

I use a trigger in Mysql that inserts newly inserted rows into multiple tables. The trigger is composed of several SELECTs. I noticed that the trigger works only when each SELECT returns a result. I understood that MySQL does not like to INSERT…
RemiC
  • 77
  • 13
0
votes
4 answers

SQL insert query for multiply rows with shared values

I have a simple table Users (name, city, country) and need to add several rows where some of values are the same (city, country). Is there a better way to insert data beside: insert into Users (name, city, country) values ("John", "Paris",…
0
votes
1 answer

Insert multiple data from other table in codeigniter

I want to save the data where id_perencanaan is selected. I've tried a lot of ways, but have not found the answer. Controller: public function salin_barang_perencanaan($id_perencanaan) { $barang_perencanaan =…
Muslim
  • 66
  • 1
  • 8
0
votes
2 answers

PHP, PDO, MySQL - Multiple INSERT vulnerable to injection?

In my application (PHP) I am going to request ~3000 rows from an API and insert these in a MySQL table using the PDO driver. Although the data to be inserted isn't user input, it is out of my hands how the data is handed to me. Because it is…
kgongonowdoe
  • 425
  • 3
  • 16
0
votes
2 answers

Codeigniter Insert Multiple Fields Using Foreach Loop

I have a problem when I want to insert multiple fields which are using foreach loop (to get the value form database), here is my form:
fqodry
  • 13
  • 1
  • 5
0
votes
0 answers

ms sql bulk insert into multiple tables with identity values

I have three tables say t1,t2, t3. Actually,t3 is result of select query with joins from many tables.I have to bulk insert the data from t3 to t1 and t2.First I have to insert some data from t3 into t1 and get the identity value from t1 and insert…
xyz
  • 762
  • 7
  • 24
0
votes
1 answer

How do I insert multiple value if there is only one value in form

I need to know how can I insert or update a value in my DB for a invoice form if the value of the input that I need to save is only one time? I have a invoice form where I select a product in every row, and finally I have the input(user_id) with the…
user3236149
  • 167
  • 4
  • 16
0
votes
2 answers

Simple SQL Server Insert - Many Comma Delimited Values from Textbox to ONE Column

This should be simple. I have a textbox (textarea) with comma separated values. Like this: 425020,547538,548029,548853,552373 I have done this two ways. One with a table that has two columns, |Number6|Number16| ... and one that just has one column…
Jason Paw
  • 96
  • 13
0
votes
0 answers

SQL - Insert multiple rows with SELECT

I am looking for an efficient way to perform inserts of multiple rows with some values from multiple tables! Basically I'm parsing an XML and creating a list of custom objects which I then want to insert to my database. Some of the values of these…