04-03 SET

01

Use this Table

DROP TABLE student;
CREATE TABLE student(
    student_id INT AUTO_INCREMENT,
    name VARCHAR(20),
    major VARCHAR(20),
    PRIMARY KEY(student_id)
);
INSERT INTO student(name,major) VALUES('John','Biology');
INSERT INTO student(name,major) VALUES('Kate','Sociology');
INSERT INTO student(name,major) VALUES('Claire','Chemistry');
INSERT INTO student(name,major) VALUES('Jack','Biology');
INSERT INTO student(name,major) VALUES('Mike','Computer Science');
SELECT * FROM student;

02

If we want to SET multiple commans, seperate the column names with commas , after the keyword SET

UPDATE student
SET name = 'Tony' , major = 'Cereal'
WHERE student_id = 1 OR name = 'Claire';

03

If we SET only the column, it will apply the value to all the rows of the column

UPDATE student
SET major = 'undecided';