Skip to content

[lab-stored-procedures] Izel - #3

Open
izelyekrek wants to merge 1 commit into
Ironhack-Data-0621-Remote:mainfrom
izelyekrek:main
Open

[lab-stored-procedures] Izel#3
izelyekrek wants to merge 1 commit into
Ironhack-Data-0621-Remote:mainfrom
izelyekrek:main

Conversation

@izelyekrek

Copy link
Copy Markdown

No description provided.

@ArabellaCM

Copy link
Copy Markdown

HI Izel. I'm taking a look at your Stored Procedures Lab.

Your queries don't quite return the results the questions have asked for. You should be sending a parameter into your stored procedure and the query inside returns the results you want according to the parameter.
So the general structure is:

delimiter //
create procedure new_procedure(in category_string int)
begin
select columns from your_table
where title = category_string
end;
// 
delimiter ;

Here is a solution to the second question which asks for a stored procedure which will return all the films of the Action category:

drop procedure if exists customer_info_by_film_category;
delimiter //
create procedure customer_info_by_film_category (in param varchar(20))
begin
    select first_name, last_name, email
    from customer
    join rental on customer.customer_id = rental.customer_id
    join inventory on rental.inventory_id = inventory.inventory_id
    join film on film.film_id = inventory.film_id
    join film_category on film_category.film_id = film.film_id
    join category on category.category_id = film_category.category_id
    where category.name = param
    group by first_name, last_name, email;
end;
//
delimiter ;

call customer_info_by_film_category("Action");

Make sure you understand how stored procedures work because they can make your life in SQL a lot smoother :) Let me know if you have any problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants