I have a database with menus and items, with a relationship between the two so that items can go on menus.
I want a select statement that can get varchar2 input from the user, and then check if the inputted value is part of the name of any items on the menus.
For example, if the user was to input 'strawberry' I would want the query to output all menus with corresponding items that have the word 'strawberry' in them. Like...
Menu Item
-------------------- -----------------------------
Valentine Theme Chocolate covered strawberry
Red Drink Theme Strawberry Margarita
Red Drink Theme Strawberry sensation
[How] is this possible? Here's what I've tried so far, and both have failed...
Try 1 :
select menu_name Menu, item_name Item
from menu m, item_for_menu i_m, item i
where m.menu_id=i_m.menu_id
and i.item_id=i_m.item_id
(and item_name = '&name_of_item'
or item_name like '%name_of_item%');
Try 2 (after some googling):
accept item_in prompt 'What item do you want to search for? '
select menu_name Menu, item_name Item
from menu m, item_for_menu i_m, item i
where m.menu_id=i_m.menu_id
and i.item_id=i_m.item_id
and item_name like item_in;
undefine item_in