Wednesday, November 8, 2017

MySQL SQL Morning

Use Sakila;
Select * from Actor;
Select * from Film;
Select * from film_actor;

Select first_name, last_name,
title, description, release_year,
rating
From actor
inner join film_actor
on actor.actor_id=film_actor.actor_id
inner join film
on film.film_id=film_actor.film_id
Where first_name like 'Pen%';

Insert into Actor(first_name,last_name,last_update)
values('Bobo','Dodo', current_timestamp());

Select * from Actor where actor_id=201;

Select last_insert_id();

Update Actor 
Set Last_name = 'Dodson'
Where Actor_id=201;

Update Actor 
Set Last_name = 'Dodson',
first_name='Bob',
last_update=current_timestamp()
Where Actor_id=201;

CRUD  /*Create Read Update Delete*/

Delete from actor;
Delete from actor where actor_id = 201;

start transaction;

Update actor 
Set last_name = 'Smith'
Where actor_id =1;

Select * from Actor;

rollback;
Commit;

No comments:

Post a Comment