Home>

UPDATE table name SET column name=value WHERE id=n;

I learned and understood this,

] (6f4df9c26ab2fa7d7bcaca6c90f577a1.png)

UPDATE Don't do it one by one,
I was wondering if I could sort out the producer names all at once.

Bulk update???

Is this the correct answer?

I tried it, but I got a syntax error

I think it's probably a very basic thing, but thank you. When I wrote it while googled, it was solved now so w

Please tell me the correct answer from your teacher.

Addendum

With this feeling, the value of the manufacturer is NULL,
When assigning each name by UPDATE at once

UPDATE my_items SET
maker = case id WHEN '2' THEN'Yamauchi' WHEN '3' THEN'Otsuka' WHEN '4' THEN'SHIMADA' WHEN '5' THEN'Journouchi' WHEN '6' THEN'Abe' END WHERE id between 2 and 6;

It was made.

  • Answer # 1

    If you only need to enter the same manufacturer name, specify where normally

    UPDATE table name SET maker='predetermined maker' WHERE id between 2 and 6;

  • Answer # 2

    If such a branch occurs, table that information and update via that table.

    <maker_list>

    ID MAKER
    2 Yamauchi
    3 Otsuka
    Four Shimada
    Five Loach
    6 Abe
    UPDATE my_items item
            inner join maker_list list
            on item.ID=list.ID
    SET item.maker=list.maker

  • Answer # 3

    UPDATE my_items SET
    maker = caseidWHEN '2' THEN'Yamauchi' WHEN '3' THEN'Otsuka' WHEN '4' THEN'Shimada' WHEN '5' THEN'Shounouchi' WHEN '6' THEN'Abe' END WHEREidbetween 2 and 6;