Last answered:

12 Nov 2022

Posted on:

05 Nov 2022

0

How to add value on previous row

INSERT INTO customers (first_name, last_name, email_address, number_of_complaints)
VALUES ('John', 'MacKinley', 'john.mackinley@365datascience.com', 0);

ALTER TABLE customers
CHANGE number_of_complaints number_of_complaints INT DEFAULT 0;

INSERT INTO customers (first_name, last_name, gender)
VALUES ('Peter', 'Figaro', 'M');

So I wrote the values on the first row, but I forgot to add 'M' on the GENDER column for John MacKinley. How to add it back?

2 answers ( 0 marked as helpful)
Instructor
Posted on:

09 Nov 2022

1

Hi Gilliane!
Thanks for reaching out.

You can simply delete this record and add it again with the new values.

Hope this helps.
Best,
Tsvetelin

Posted on:

12 Nov 2022

0

you can also use update clause
(update customers
set email_adress = 'peter.figaro@gmail.com'
where customer_id = 2)
I think this will work
in your case it will be
update customers
set gender =  'M'
where customer_id = 1;

Submit an answer