The given SQL creates a song table and inserts three songs.
Write three UPDATE statements to make the following changes:
Change the title from 'One' to 'With Or Without You'.
Change the artist from 'The Righteous Brothers' to 'Aritha Franklin'.
Change the release years of all songs after 1990 to 2021.
Run your solution and verify the songs in the result table reflect the changes above.
CREATE TABLE song (
song_id INT,
title VARCHAR(60),
artist VARCHAR(60),
release_year INT,
PRIMARY KEY (song_id)
);
INSERT INTO song VALUES
(100, 'Blinding Lights', 'The Weeknd', 2019),
(200, 'One', 'U2', 1991),
(300, 'You\'ve Lost That Lovin\' Feeling', 'The Righteous Brothers', 1964),
(400, 'Johnny B. Goode', 'Chuck Berry', 1958);
-- Write your UPDATE statements here:
SELECT *
FROM song;

Respuesta :

Answer:

  • UPDATE song SET title = 'With Or Without You' WHERE song_ID = 200
  • UPDATE song SET artist = 'Aritha Franklin' WHERE song_ID = 300
  • UPDATE song SET release_year = 2021 WHERE release_year > 1990

Explanation:

Given

The above table definition

Required

Statement to update the table

The syntax of an update statement is:

UPDATE table-name SET column-name = 'value' WHERE column-name = 'value'

Using the above syntax, the right statements is as follows:

  • UPDATE song SET title = 'With Or Without You' WHERE song_ID = 200

The above sets the title to 'With Or Without You' where song id is 200

  • UPDATE song SET artist = 'Aritha Franklin' WHERE song_ID = 300

The above sets the artist to 'Aritha' where song id is 300

  • UPDATE song SET release_year = 2021 WHERE release_year > 1990

The above sets the release year to '2021' for all release year greater than 1990

Otras preguntas