sql - Using ONLY Entity Relationship Diagram to Query MYSQL Format [BRAIN CHALLENGE] -
normally query using tables , schema in case have use entity relationship diagram query on piece of paper in mysql format.
these making things complicated. require example question.
based on data above inner join
s written this:
select * wines inner join carry on wines.wine_id = carry.wine_id
notice diagram relationship between wines , caries shows 0 many (1..1 - 0..*). notice wine_id not listed in carry table column list implied throught relation.
next want know price today (hint: since table carry table has price_start_date
, price_end_date
implies prices not fixed , need use these fields):
where price_start_date <= curdate() , curdate() <= price_end_date
to prices below $15:
where price_start_date <= curdate() , curdate() <= price_end_date , price_on_carry < 15
question 1 query below (you need add relevant column names):
select * wines inner join carry on wines.wine_id = carry.wine_id price_start_date <= curdate() , curdate() <= price_end_date , price_on_carry < 15 , wines.color = 'red'
note: english not first language confused "whether or not canada", if need include information whether wine canada or not. assumed don't need include information.
Comments
Post a Comment