Sorting conditions

Report a typo

You should write a procedure named shopping that puts an item into one of the following baskets red_basket, green_basket or other_basket based on its color. Copy the given template into the input field and replace ToDo... with the correct IF statements.

CREATE PROCEDURE shopping(
    item_name VARCHAR(30),
    color VARCHAR(30))
BEGIN
    # First ToDo...
INSERT INTO red_basket(item) VALUES (item_name);
    # Second ToDo...
INSERT INTO green_basket(item) VALUES (item_name);
    # Third ToDo...
INSERT INTO other_basket(item) VALUES (item_name);
    # End ToDo...
END;

There are some calls below that should successfully work with this procedure. Take a look at their parameters to understand how to write correct IF statements and put the items into suitable baskets.

CALL shopping('jacket', 'green');

CALL shopping('hat', 'red');

CALL shopping('pants', 'red');

CALL shopping('shoes', 'green');

CALL shopping('umbrella', 'yellow');

Write an SQL statement





___

Create a free account to access the full topic