I request help for my homework in SQL.
I have a table with musical instruments:
id instrument_name instrument_at_shops
-----------------------------------------------
1 Electric Guitar 1;2;3;4;
2 Midi Keyboard 1;3;
3 Tom Drum 2;
4 Electric Guitar 1;
5 Electric Guitar 0;
And a table with shops:
shop_id shop_name shop_address
-----------------------------------------------
1 Shop1 City1 Street 1, building 1
2 Shop2 City1 Street 5, building 4
3 Shop3 City2 Street 4, building 4
4 Shop4 City3 Street 10, building 7
In my musical instruments table I have several numbers which represent id's of the shops that have the particular instrument.
The problem is: how to create a view which contains a shop name and an instrument which is in this shop?
The logic is this:
SELECT shop_name, instrument_name
FROM Shop
CROSS JOIN Instrument
WHERE instrumet_at_shops CONTAINS shop_id
But I cannot create an appropriate query or view design.
Thank you in advance!