All Questions
Tagged with insert-update mysql
364
questions
0
votes
2
answers
49
views
Update scenario is not working properly when using CASEs or IF statement ON DUPLICATE KEY UPDATE section in MySQL
I need to do bulk insert and update on MySQL so I used the ON DUPLICATE KEY UPDATE. I need to ignore the updated by and updated date fields as existing old data if there are no changes in those record'...
-1
votes
1
answer
44
views
If I have multiple entries in a cloumn in mysql that need to be changed
So I want to change all the fields in the column allow_two_day_ordering to False. How can I change them all without doing it one by one. I have a much bigger list than this.
+-------+------------------...
0
votes
1
answer
40
views
How can I UPDATE a column in a record when that information is the result of a GROUP CONCAT in the same table?
I cannot determine if this should be something nested or a JOIN.
Each record has three values from the column value across from their name in the column variable.
I have a successful GROUP CONCAT that ...
0
votes
1
answer
61
views
How to improve this INSERT code with ON DUPLICATE KEY UPDATE
I had this code:
for chunk in np.array_split(DataFrame, 20, axis=0):
for i in chunk.index:
cursor.execute("INSERT INTO table (col1, col2, col3, col4) VALUES (%s, %s, %s, %s) ON ...
1
vote
2
answers
58
views
Should primary key columns be added in the UPDATE?
In the example code below, col1 and col2 are primary keys in the database!
My question is: should they be added in the part of the code after the ON DUPLICATE KEY UPDATE, as it is already in the code, ...
0
votes
0
answers
61
views
MYSQL SELECT statement failing within an UPDATE, within a LOOP
I am writing a stored procedure to update a company calendar. The calendar data is stored within a MYSQL table. The stored procedure is an insert function which should force all calendar events ...
0
votes
1
answer
1k
views
INSERT ... ON DUPLICATE KEY UPDATE causes Deadlock Exception in Mysql 5.7
We are having a mysql table like below
CREATE TABLE student_subject (
student_subject_id int(11) NOT NULL AUTO_INCREMENT,
student_id int(11) NOT NULL,
subject_id int(11) NOT NULL,
version int(...
1
vote
0
answers
27
views
What is the most efficient way to update the value of another table in MYSQL?
Scenario
1. Two tables exist called 'score_log' and 'games_played_count'
2. Computing the "count" of rows from score_log that uniquely describe the number of games that have been played by a ...
0
votes
1
answer
267
views
Error creating Trigger After Insert in Mysql
I'm stuck when creating my trigger in mysql (on phpmyadmin), and that's why I come to ask for your help
I have 2 tables : Assemblage and Bicyclette.
Tables Diagram:
Assemblage was built like this :
...
-1
votes
1
answer
97
views
How to INSERT INTO SELECT by considering IF EXISTS rules in MySQL? [duplicate]
In MySQL its possible to insert data retrieved from another table, e.g.:
INSERT INTO
`table2`
(
`table2_id`,
`foo`
)
SELECT
`id`,
`foo`
FROM
`table1`
WHERE
....
-1
votes
1
answer
129
views
UPDATE NULL of a column matching the ID in the same table
I'm working on housing data with several columns. In the cleaning process, I noticed that in the column 'PropertyAddress' are a few Null, and I want to confirm if those Null could be matched with the ...
0
votes
0
answers
279
views
How to Convert SQL Server Query to MySQL Query
I'm trying to convert this SQL Server query to MySQL query
how can i do that?
Fallowing is my SQL server query. I need to convert this query to execute in MySQL.
EpfNO is the Primary key and ...
0
votes
0
answers
45
views
INSERT or UPDATE : importing data and managing update
I face an insolvable issue (for me).
I have a client table
CREATE TABLE `client` (
`cli_id` INT NOT NULL,
`cli_active` SMALLINT NOT NULL DEFAULT 1,
PRIMARY KEY (`cli_id`));
According that we ...
0
votes
1
answer
194
views
MySQL while loop insert
I am facing a very strange problem with while loop insert on MySQL
Here's the background information of my test:
CREATE TABLE test_table (
`token` varchar(16) NOT NULL,
`val1` varchar(256) DEFAULT ...
0
votes
1
answer
46
views
Inserting 0s for dates currently without data, after a key's first appearance
I've got a table that looks something like the following
Date
Key
Metric
2021-01-31
A
6
2021-02-28
A
3
2021-05-31
A
3
2021-03-31
B
4
2021-04-30
B
1
2021-05-31
B
2
What I'd like to do is insert ...