Questions tagged [sql-insert]
The SQL INSERT statement allows you to insert a single or multiple rows into a table.
5,466
questions
0
votes
0
answers
8
views
How to upsert list data into oracle using cx_oracle?
I'm trying to upsert(update data if exist,else insert ,which is like 'replace into' in mysql) into oracle using cx_Oracle.
However my code now seems to insert directly into the table
without matching ...
0
votes
1
answer
19
views
Optimizing data fetching and insertion in Spring Boot
I have 270000 records in a CSV file with columns user_id, book_ISBN, and book_rating, I need to insert the records into a many-to-many table.
I parsed the data with openCSV library and the result is a ...
0
votes
0
answers
14
views
Check if value exist in specific row database [duplicate]
I want check if a value exist in database and if she exists : update database else : insert into database,
my database looks like
meta_id | post_id | meta_value | meta_key
Primary | int | value ...
0
votes
0
answers
25
views
Insert data from table A into table B with different column names, using a stored procedure
Tried to use a cursor to cut and input data from table A into table B, but keep returning a syntax error. This is for a school project, much appreciated.
CREATE OR REPLACE PROCEDURE public....
0
votes
0
answers
28
views
no such column (pyhon tkinter)
i want to store all table's names in a list to then print in another window.
But when i try to put those names in the new table i create, it givese me: "OperationalError: no such column: and the ...
0
votes
0
answers
17
views
how to insert query for annotation insert with parameter list in mybatis?
I able to insert data if without list parameter but i need it.
Can any know how to do it using mybatis annotation @Insert with list Parameter?
//purchase_item_cart error since its list
@Insert(&...
0
votes
0
answers
22
views
CodeIgniter 4 : no error but data won't insert to database
No error while I try to insert the data. in fact the session indicator shows that I successfully inserted the data, but when I check the database it was nothing.
public function save_agenda()
{
...
0
votes
0
answers
40
views
psql insert into if else
I want to make it so that when creating a user, the first user receives $ 1000 on the wallet, and the rest - $ 10 (user_id - pk)
I made this request
INSERT INTO users (user_id, login, balance, ...
1
vote
1
answer
30
views
How to insert a row into a table with a composite foreign key referencing a composite primary key
I have a table called BB:
CREATE TABLE BB (
SID INTEGER PRIMARY KEY,
FName TEXT,
LName TEXT
);
And a table called QR that contains a composite foreign key referencing the FName and LName ...
0
votes
2
answers
31
views
Insert row into an empty table with INSERT ... SELECT ... FROM command in SQL
I'm going to make a new table (PersonInformation) with columns of another one(Members) and some more columns like "Username", "Password" and "PersonId".
The command I ...
-2
votes
2
answers
77
views
SQL Error Msg: A SELECT INTO statement cannot contain a SELECT statement that assigns values to a variable
I get the error
A SELECT INTO statement cannot contain a SELECT statement that assigns values to a variable
when I run the following lines of code on Microsoft SQL Server 2016. I am trying to use ...
-1
votes
0
answers
22
views
MySQL - Upsert multiple rows at once (INSERT INTO ON DUPLICATE KEY UPDATE) with NodeJS
I'm trying to upsert (insert or update) about 500 rows in one query.
I started with a REPLACE INTO query which works fine:
function getSQLRows(withPrimaryKey) {
return [rows.map(item => {
...
0
votes
1
answer
22
views
Insert data from column as average in another table in mysql
I have a table named feedback which has columns mechEmail (foreign key) and rate in it.
I have another table named mechanical which has columns email (primary key) and avgrate.
I want to insert the ...
0
votes
1
answer
39
views
Undo insert query in SQL Server
I ran an insert query on a table in SQL Server by mistake and 100 rows got inserted. I want to undo it but I do not have rollback.
0
votes
0
answers
31
views
When inserting a result of a query, how do I insert random exact numbers?
I can use IDENTITY to generate unique ID numbers, but is there a way to generate a completely random number when inserting data? Currently, all ID's start with "1000"
Here is my original ...
0
votes
1
answer
20
views
PostgreSQL Instead of Insert Trigger return NULL for default value. How to fix that?
I am using Postgres 13 version and seeing strange behaviour on Instead of Insert trigger.
In the output of Insert trigger Default values are NULL. But the value is provided in column, how should I ...
-1
votes
0
answers
13
views
Using Insert Into in SQL
I have 2 tables. Table 1 has a many columns, including fica_number, but not employee ID. Table 2 has many columns, including fica_number AND employee id. I wanted to use Insert Into to add the ...
0
votes
2
answers
54
views
INSERT INTO SELECT without duplicates MSSQL
So the thing is I have two CTEs from which I want to insert the values in a table.
In the P CTE I have 50 registrations, while in the M CTE I have 8. What I want is to insert in destination table all ...
2
votes
1
answer
42
views
Insert into JSON objects postgres using Node without forloop for every db.query
I have an array of objects like with the same setup as the one below. I wanna insert this array of objects into postgres table that looks like this:[![Table setup][1]][1]
I have tried to make a ...
1
vote
1
answer
57
views
Inserting aggregates into big table is too slow
I need to run a query as cronjob and it is too slow to perform. It sums a value from a view table (data_time_series) for each pair of aks and ii and inserts a row in storage_time_series if those ...
-1
votes
0
answers
24
views
I have 29638 row to enter in my table. I used one of the solutions from a previous question but got an error message that the identifier is to long
I have 29638 row to insert into sql. Im used a solution from a previous question INSERT [HCO2].[Visits].[Biglist]... I got a error Msg 103, Level 15, State 4, Line 13
The identifier that starts with ' ...
0
votes
1
answer
44
views
Postgres - How to delete a row with its sequence? [duplicate]
I created a table called Product with a serial ID in Postgres:
CREATE TABLE PRODUCTS (
PRODUCT_ID serial PRIMARY KEY,
NAME VARCHAR ( 100 ) NOT NULL );
If I deleted a row with
DELETE FROM PRODUCTS ...
-1
votes
1
answer
29
views
SQLite string search in rows then insert string into new rows with values of the same row last column
I want to provide a query to my database that will search if a string exists in Column2(site_id) then put that string in a new table with the value of its before column in that row.
the table has only ...
1
vote
1
answer
42
views
Update on Duplicate key with two columns to check mysql
I am trying to get my head around the 'On Duplicate Key' mysql statement. I have the following table:
id (primary key autoincr) / server id (INT) / member id (INT UNIQUE KEY) / basket (VARCHAR) / shop ...
0
votes
2
answers
28
views
Insert rows from TableA that are not in TableB using concatenated keys
I have 2 tables. TableA gets populated by a csv import and typically contains between 10k and 15k rows. TableB has the same structure, and has now grown to about 95k rows. In order to determine ...
0
votes
1
answer
33
views
CASE WHEN Statement error in SQL: Column name or number of supplied values does not match table definition
I included everything relevant up until the error, but everything has worked and run fine prior to the case statement code; upon running I get the error "Column name or number of supplied values ...
-1
votes
0
answers
28
views
C# Insert statement does not complete for MariaDB, no new data shows or 'Cannot add or update a child row: a foreign key constraint fails'
When I insert data with MySqlCommand the data will either not be present in the database table or give an error. The required records do exist in the Foreign table, so why does it not complete the ...
0
votes
1
answer
26
views
Liquibase insert select multiple rows postgres
I want to insert into table1 multiple rows from table2. The problem is that I have some fields in table1 that I want to compute, and some rows that I want to select from table2. For example something ...
1
vote
1
answer
30
views
SQLite Copy Table Content from one Table to another Table and Update
I have two SQLite files, each of them has one table and the same table design. One Column is set as Primary Key. I want to copy all data from ItemsB into ItemsA. All data should be updated. The ItemsB ...
2
votes
1
answer
41
views
Insert into on duplicate key query for custom update on each row
I can insert/update data based on the following query on a MySQL server.
INSERT INTO users (user_id, books)
VALUES
(1, “book1, book2”),
(2, “book3, book4”)
ON DUPLICATE KEY UPDATE books=“book1, ...
1
vote
0
answers
48
views
Creating a Complex Insert Statement
So I’ve been trying to create an Insert statement for a report I am making, that draws information from several other tables, Columns and concatenates some of the columns.
So far I have this and it ...
-1
votes
0
answers
40
views
Insert from OPENJSON and another table using where clause
I am trying to insert json into Invoice table but this query is giving me error on Invno column:
The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Invoice_InvM". The ...
1
vote
1
answer
16
views
SQLite conditionals in creation of a trigger
I'm creating a trigger using SQLite and I want to compare if the OLD value is different than the NEW value so I can execute an INSERT
This is the trigger I created but seems like the MySQL syntax does ...
1
vote
1
answer
18
views
SQLite using NEW in subquery in a trigger
I'm trying to create a trigger that classifies some news in my database by category after every insert on the table news if the attribute title contains "COVID-19" or "coronavirus" ...
0
votes
1
answer
56
views
"WITH AS" Working in Postgres but not in H2 dabatabse
I am writing a single query to insert data into 2 tables using "WITH AS". The query works fine on Postgres but on H2 database it is throwing syntax error.
I have 2 tables.
Table 1 has 2 ...
0
votes
1
answer
29
views
Date Values format for MySql
my plan is to insert the date (day_of_test) into a MySql database, where the dataformat is referenced as a Date.
I have to keep the syntax in the format you see below. But unfortunately my attempts to ...
-2
votes
1
answer
34
views
PHP - HTML -JAVASCRIPT Copying values from form A into form B and using those from Form B as input for DB
This is what i have so far.
To get the values from form A:
$('.table tbody') .on('click','.btn',function(){
var currow = $(this).closest('tr');
var col1 = currow.find('td:eq(1)').text();
var col2 = ...
1
vote
1
answer
63
views
How to Update and Insert Array of Objects in table with OPENJSON and where conditions
I want to update and insert the stock, InvM, and Invoice table with OPENJSON(). I am new at OPENJSON() in SQL Server. I have an array of objects and I want to insert each object to new row of the ...
0
votes
1
answer
40
views
Log errors into error table in insert statement
I came across an error invalid identifier in the error table even though the fields are present in the error table. The below is my test code for your reference. Any update absolutely appreciated.
...
0
votes
2
answers
61
views
How to insert into table a new row then do nothing if already exists(without UNIQUE key)
Let's say I have these two tables. Where I insert employees to employee table coming from the staging table.
staging table:
id
employee_id
name
1
12
Paul
2
13
Kyle
employee table
id
employee_id
...
0
votes
2
answers
69
views
SQL query (insert into) in oledb without duplicates in VB.NET
I want the SQL query command (insert into) in oledb without duplicates and is there the best recommendation?.
Thanks
jack
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System....
-1
votes
1
answer
24
views
Insert array / nested table into table
I really apologise if answer already was given, but I could only find answers for php.
My problem is that I got nested table array "test_nested_table" that got values ('a','b','c'). I also ...
0
votes
0
answers
21
views
Insert/update UNIQUE random id from another table using postgresql implemented in java
so I am stuck on this problem.
I want to generate random(but unique) data in my table.
I have table of products with id. And table warehouse - where I want to insert/update product_id. But it has to ...
1
vote
1
answer
43
views
Insert multiple values with the same foreign key
I have two tables that reference each other:
CREATE TABLE Room
room_id INTEGER PRIMARY KEY,
room_name TEXT UNIQUE NOT NULL;
CREATE TABLE Item
item_id INTEGER PRIMARY KEY,
room_id ...
1
vote
1
answer
57
views
Inserting Values Into Table Oracle SQL Not Working
I have a few lines that have worked in the past for inserting new values into an existing table.
INSERT INTO TABLE_NAME (OLD_NAME, NEW_NAME, COUNTED, ORIGIN)
VALUES ('old name', 'new name', null , ...
0
votes
1
answer
33
views
Unable to Insert/Create Table from Query Results in IMPALA
select *
into temp_DB.TEMP2
from MyDb.Mytable
Error:
AnalysisException: Syntax error in line 2:undefined: into MyDb.Mytable ^ Encountered: INTO Expected: FROM, LIMIT, ORDER, UNION, COMMA CAUSED BY: ...
0
votes
1
answer
64
views
Create stored procedure Insert and Update
I'm trying to insert and update queries at the same time in stored procedure, but I get a syntax error:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB ...
0
votes
0
answers
55
views
How can I update row in a stored procedure used linked server
I need to update a table in the linked server in the procedure, but I could not succeed.
The SELECT statement succeeds, but I cannot UPDATE or INSERT.
This procedure worked in the web application(ASP) ...
0
votes
0
answers
19
views
For loop does not insert table content in postgresql [duplicate]
I want to insert some testing data into my Customers table. I am using Postgresql and I am trying to do this using a for loop.
When I insert the data only once, it works just fine:
do $$
declare ...
0
votes
0
answers
30
views
Why is my SQL INSERT INTO statement going straight to error?
I am creating a login system but the INSERT INTO statement isn't working. I have used this code previously & it has worked perfectly, however when I run this it goes straight to "ERROR IN ...