select - Compare row name with one cell in sql -
i have 2 tables. 1 table id, date, menu1, menu2, menu3 , table id, id_date, number, menu_number.
in second table there data users have ordered menu in specific day. example: id: 1 id_date: 2014-09-09 number: 4000 menu_number: menu1. , information want give out number, date , menu on date stands in first table.
select distinct b.id, b.id_date, b.menu, s.date ordering b, menu_plan s b.id_date = s.date , b.number = '4000859'
this sql statement gives me menu number specific day. want content menu on specific day table 1. how work? or should in way , write in second table instead of menu number full menu?
select distinct b.id, b.id_date, menu = case s.menu_number when 'menu1' b.menu1 when 'menu2' b.menu2 when 'menu3' b.menu3 else 'unknown' end, s.date ordering b join menu_plan s on b.id_date = s.date b.number = '4000859'
Comments
Post a Comment