Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The following questions will help you to practice writing SQL statements. The qu

ID: 3913592 • Letter: T

Question

The following questions will help you to practice writing SQL statements. The questions are based on the "sakila" database schema on MySQL Workbench.

1. Write the sql statement that will provide you a list of actors with first name "Sandra" and also other records with last name "Bullock". How many rows were found?

2. Write the sql statement that will provide you a list of films acted by the first name "Sandra" and last name "Bullock" combination without showing duplicates.

3. You suspect that the names were mixed up at some point, and you know that "Sandra Bullock" only acts in documentaries, therefore. Write the sql statement that will provide you a list of documentary films that you suspect Sandra Bullock was the actor. (That either had first name "Sandra" or last name "Bullock".) How many rows were found?

4. Write the sql statement that will UPDATE the first name of only those films to Sandra. (Wrap your UPDATE around a START TRANSACTION and ROLLBACK)

5. Write the sql statement that will UPDATE the last name of only those films to Bullock.  (Wrap your UPDATE around a START TRANSACTION and ROLLBACK)

Explanation / Answer

1.

Select first_name,last_name from actor where first_name = 'Sandra' or last_name = 'Bullock';

2.

Select distinct first_name,last_name from actor where first_name = 'Sandra' or last_name = 'Bullock';

3.

Select first_name,last_name from actor where first_name = 'Sandra' and last_name = 'Bullock';

4.

Start Transaction;

Update actor set first_name = 'Sandra' where last_name = 'Bullock';

Rollback;

5.

Start Transaction;

Update actor set last_name = 'Bullock' where first_name = 'Sandra';

Rollback;

Do ask if any doubt. Please upvote.