Q
Q
Quotro2017-03-06 12:25:23
MySQL
Quotro, 2017-03-06 12:25:23

How it is? Did the Update command Truncate the tables?

20 Update requests, I wanted to optimize them. To merge these 20 requests into one, the WHEN - THEN construct was used. Late, fatigue, mistake.
As a result of the query, all values ​​in the brand_sku_increment table disappeared!
Yes, everything was restored, but I can not understand how this could happen. When there is a syntax error, an error warning is displayed and the command simply fails.

UPDATE brand_sku_increment SET `sku_brand`= CASE
WHEN product_sku = 'G-60019 THEN '00006-1'
WHEN product_sku = 'G-40015' THEN '00001-1'
......

END 
WHERE 1

Help to understand what caused truncate.
product_sku and brand_sku - primary key Ca
n't they be changed from inside the table at all?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton, 2017-03-06
@Quotro

It is this CASE WHEN that bothers me more. After all, you only have THEN, but you don't have ELSE. In theory, if ELSE is omitted, then you need to insert a NULL value. And also the WHERE 1 condition is alarming

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question