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
1
vote
4 answers

Microsoft sql server 2014 Error on insert

When I insert into table with this code I have this error. INSERT INTO Ridic values( 1, 'Franta' , 'Popkorn' , 2, 'Slavěna', 'Zíková' , 3, 'Havel' , 'Bravenec' , 4, 'Rudolf' , 'Stibor' , 5, 'Miloš' , 'Vorlíček' , 6, 'Agáta' ,…
Daffy
  • 33
  • 7
1
vote
2 answers

Android SQLiteDatabase inser error

I'm trying to store in a SQLiteDatabase some information. When I call the method insert, it returns -1. So an error occurred, but I can't figure out what is wrong. Here's the code: public class SQLiteHandler extends SQLiteOpenHelper { private…
Andrea R.
  • 33
  • 7
1
vote
1 answer

Insert into view and use default values for the underlying table

I have a table e.g. Customers(CustomerType, Name) and two views for each customer type: create view PremiumCustomers as ( select Name from Customers where CustomerType = 1 ); and create view NormalCustomers as ( select Name from Customers where…
xpy
  • 5,481
  • 3
  • 29
  • 48
1
vote
1 answer

MySQL INSERT statement not executed

I cannot for the love of god figure out why this statement is not executing. When I limit it to mysql_query("INSERT INTO my_pets() VALUES ()", $con); it fires just fine, creating an empty row (NULL in every cell), but as soon as I give it columns…
VHK
  • 89
  • 5
1
vote
2 answers

When inserting to multiple tables, what is the best approach for this matter?

I'm not sure if there is a debate about this. When I read books, I'm advised to use triggers to follow up inserts into other tables. On the other hand, my mentor uses stored procedures to insert into the other tables. My question here, which is the…
Joshua Rajandiran
  • 2,788
  • 7
  • 26
  • 53
1
vote
1 answer

SQLite, SQL: Using UPDATE or INSERT accordingly

Basically, I want to insert if a given entry (by its primary key id) doesn't exist, and otherwise update if it does. What might be the best way to do this?
Hamster
  • 557
  • 2
  • 7
  • 12
1
vote
1 answer

write SQL insert, update and delete commands in a batch file

Can I write SQL insert, update and delete commands in a batch file? If I can do so can someone give me an example please.
1
vote
2 answers

postgresql - use just created identity value to return newly inserted row

Using SQL Server I can write the following statement... create table Person( id int identity(1,1), name varchar(50) ) insert into Person(name) values ('John') select * from Person where id = scope_identity() In Postgres I can do…
John Livermore
  • 30,235
  • 44
  • 126
  • 216
1
vote
2 answers

SQL Server - Insert lines with null values when month doesn't exist

I have a table like this one: Yr | Mnth | W_ID | X_ID | Y_ID | Z_ID | Purchases | Sales | Returns | 2015 | 10 | 1 | 5210 | 1402 | 2 | 1000.00 | etc | etc | 2015 | 12 | 1 | 5210 | 1402 | 2 | 12000.00 | etc | …
rffs
  • 45
  • 1
  • 1
  • 5
1
vote
0 answers

How to add Unicode characters from MySql Command to database

i am adding Unicode character data to database from MySQL insert command it is showing question mark in output webpage.But when i am adding this data from admin panel it is showing correctly.I want to add data from mysql command so please help.
1
vote
2 answers

MySQL inserting same rows

There is a sql table like that Indexes like that INSERT INTO users_words(iduser,idword,status_of_word) VALUES(4,6,2); INSERT INTO users_words(iduser,idword,status_of_word) VALUES(4,6,1); INSERT INTO users_words(iduser,idword,status_of_word)…
Hayrullah Cansu
  • 262
  • 5
  • 14
1
vote
1 answer

How to create and insert n rows of test data of random strings into table in Postgres with SQL?

In SQL in Postgres, how do I create and insert n number of rows of test data with random strings length x? e.g., CREATE TABLE my_table (my_text_column TEXT); -- now insert n rows of test data into my_table, with random -- strings of length x for…
Rob Bednark
  • 25,981
  • 23
  • 80
  • 125
1
vote
5 answers

how to insert data in database when I have two different names in my html for one column?

I know my title is a bit confusing so I'll explain it further on here. I know how to insert data in database, but I do not know how to do it when I have two different names in my HTML that should be inserted in my database. I have a dropdown list…
Felix
  • 85
  • 1
  • 10
1
vote
2 answers

inserting current date values into columns

Can you insert current date via a function with an insert statement? Should look something like this: insert into table name values (getdate(), getdate()-1) ,(getdate(), getdate()-1) The above example may be vague but can this concept be done?
AK SQL
  • 57
  • 6
1
vote
1 answer

Insert statement with subquery and extra column

I want to use insert statement with select subquery from another table. In my case, I want to add a row from PRESENTATION table to AVAILABILITY table. AVAILABILITY table structure: availableID (number, generated using sequence) availableDay …
Elly
  • 97
  • 1
  • 1
  • 9
1 2 3
99
100