Questions tagged [sql-insert]

The SQL INSERT statement allows you to insert a single or multiple rows into a table.

SQL INSERT statement adds one or more rows to a single table in a relational database.

The basic INSERT values syntax is:

INSERT INTO table [ (column1 [, column2, column3 ... ]) ]
VALUES (value1 [, value2, value3 ... ]);

The INSERT SELECT syntax is:

INSERT INTO table [ (column1 [, column2, column3 ... ]) ]
SELECT c1 [, c2, c3 ... ] FROM table

Reference

For questions regarding SQL INSERT statement use this tag instead of .

5071 questions
6
votes
0 answers

Postgres 9.6: Insert into view with on conflict

I have 2 tables both with unique constraints, 1 view that joins those 2 tables and an INSTEAD OF INSERT trigger that allows INSERT or UPDATE on the view. Everything works perfectly for regular INSERT or UPDATE but if I do INSERT .. ON…
6
votes
1 answer

There is a column named ... it cannot be referenced from this part of the query sub query

WITH upt as ( UPDATE backend."orders" SET "statusId" = 5 WHERE "userId" IN (177962,88265) and "statusId" IN (0,1,2,3,4) RETURNING * ) INSERT INTO __test_result(orderid) VALUES ((SELECT orderid FROM upt)) Need to update and log data,getting this…
Grigor
  • 499
  • 1
  • 9
  • 19
6
votes
2 answers

Insert date value in SQL table

I have the following table : EMPNO(number), ENAME(varchar), JOB(char), MGR(number), HIREDATE(date), SAL(number), DEPTNO(number) I try to insert the following : insert into EMP_TF1605(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, DEPTNO) values(7369,…
terrifurness
  • 61
  • 1
  • 1
  • 2
6
votes
1 answer

How to connect and insert record to mysql using c language?

Hello friends, My question is, can i connect mysql with c language? And if connection is possible so how to insert record to mysql database. Please give simple and small example. If any query so comment please.
Mayur Vora
  • 922
  • 2
  • 14
  • 25
6
votes
1 answer

Postgres bulk INSERT function using JSON arguments

Here's a plpgsql function for postgres 9.6. It tries to INSERT a row, and if the insert doesn't fail (due to a key constraint violation), then it runs a few more commands. CREATE FUNCTION foo(int, text, text) RETURNS void AS $$ BEGIN INSERT INTO…
user779159
  • 9,034
  • 14
  • 59
  • 89
6
votes
2 answers

INSERT value using SELECT in mysql

I have 2 tables: users with columns (id,username, password), and user_failed with columns (user_id, failed, time). is there any possible way i can insert into table user_failed by only using username? i try this code but it failed: INSERT INTO…
Ying
  • 1,282
  • 4
  • 19
  • 34
6
votes
1 answer

SQLMAP - how to insert into a database if stacked queries are not possible on a MYSQL server?

Pulling database tables and columns works fine using SQLMAP, but as I try to execute an INSERT statement I get the following error: query: sqlmap -u "http://www.example.com/details.php?item_id=327" -D main_db -T orders --columns --sql-query \…
Edmond Tamas
  • 3,148
  • 9
  • 44
  • 89
6
votes
1 answer

How to insert three new rows for every result of a SELECT query into the same table

I am using SQL Server. For every: select * from ServiceItems where Itemtypeid=7004 (query1) I want to insert into the same table three new rows like: (ItemID, PackageID, ItemTypeID, ServiceID, ItemName, CreatedDate) VALUES (19377, 5352, 7007, 2011,…
Giannis Grivas
  • 3,374
  • 1
  • 18
  • 38
6
votes
3 answers

SQL Server 2014 Insert Where NOT IN

There are 2 tables. The first has fname (first name), lname (last name) and the second has many columns including: salutation (Mr, Dr etc), fname (first name), mname (middle name), lname (last name), a uniqueidentifier and a date. I wish to create a…
user3767204
6
votes
2 answers

Valued inserted in table in oracle not saved?

I am using Oracle Database 11g and use the SQL command line. I created the tables and then inserted the values as usual .When i use the select query to see the inserted rows i see them without any problem. SQL> connect Enter user-name: hotel Enter…
6
votes
5 answers

Error: The conversion of a nvarchar data type to a smalldatetime data type resulted in an out-of-range value

Hey all I'm trying to do the following insert query SqlDataSource userQuizDataSource = new SqlDataSource(); userQuizDataSource.ConnectionString = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=quizApp;Integrated…
c11ada
  • 4,302
  • 15
  • 48
  • 62
6
votes
5 answers

NullPointerException when executing PreparedStatement on Oracle DB to insert Blob

does anyone have an idea what i am doing wrong here? I am trying to insert a blob (that contains a pdf in case that matters) into an oracle db together with some additional information. I am using a PreparedStatement Code: public void…
olkoza
  • 715
  • 2
  • 17
  • 35
6
votes
4 answers

MYSQL - INSERT error, unknown column in field list

i keep getting the following error from this simple mysql statement and i cant see why. im sure its something obvious. require_once("connect.php"); $query = mysql_query("SELECT * FROM accounts ORDER BY id DESC LIMIT 1"); $row =…
6
votes
4 answers

Load data from CSV inside bit field in mysql

What's the right syntax to insert a value inside a column of type bit(1) in `MySQL'? My column definition is: payed bit(1) NOT NULL I'm loading the data from a csv where the data is saved as 0 or 1. I've tried to do the insert using: b'value' or…
Atropo
  • 12,231
  • 6
  • 49
  • 62
6
votes
4 answers

SQL Insert record if doesn't exist

What I am trying to do is compare a table with another temporary table and if the record does not already exist insert it into the table. My problem is the IF NOT EXIST doesn't seem to be correct. If i pull the code apart the problem I have…
user2158168
  • 63
  • 1
  • 5