[lab-stored-procedures] Izel - #3
Open
izelyekrek wants to merge 1 commit into
Open
Conversation
|
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. 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.