CREATE OR REPLACE VIEW food600.slimity_polozky
 AS
 SELECT nlimity.idriadok,
    nlimity.id_limit,
    nlimity.id_den,
    nlimity.id_rov,
    nlimity.c_karty,
    nlimity.vlastnik,
    karty.nazev,
    karty.c_druh,
    karty.c_druhs,
    karty.c_druhk,
    nlimity.cena_prod,
    nlimity.dan,
    nlimity.mnozstvi,
    nlimity.c_stredisk,
    nlimity.poradie,
    nlimity.poznamka,
    nlimity.polka,
    nlimity.c_hlad,
    nlimit_hladiny.hladina,
    nlimity.id_fmenu,
    food_dat.id AS id_man
   FROM food600.nlimity
     JOIN food600.karty ON nlimity.c_karty = karty.c_karty
     LEFT JOIN food600.food_dat ON nlimity.c_stredisk = food_dat.c_stredisk
     LEFT JOIN food600.nlimit_hladiny ON nlimity.id_limit = nlimit_hladiny.id_limit AND nlimity.c_hlad = nlimit_hladiny.c_hlad
  WHERE (nlimity.id_rov IN ( SELECT slimity_zoznam.id_rov
           FROM food600.slimity_zoznam))
union 
 SELECT 0 idriadok,
    nlimitrov.id_limit,
    nlimitrov.id_den,
    nlimitrov_hladiny.id_rov,
    0 as c_karty,
    '' as vlastnik,
    '' as nazev,
    0 as c_druh,
    0 as c_druhs,
    0 as c_druhk,
    0 as cena_prod,
    0 as dan,
    0 as mnozstvi,
    0 as c_stredisk,
    0 as poradie,
    '' as poznamka,
    1 as polka,
    nlimitrov_hladiny.c_hlad,
    nlimit_hladiny.hladina,
    '' as id_fmenu,
    '' AS id_man
   FROM food600.nlimitrov_hladiny
     JOIN food600.nlimitrov ON nlimitrov.id_rov = nlimitrov_hladiny.id_rov
     LEFT JOIN food600.nlimit_hladiny ON nlimitrov.id_limit = nlimit_hladiny.id_limit AND nlimitrov_hladiny.c_hlad = nlimit_hladiny.c_hlad
  WHERE (nlimitrov_hladiny.id_rov IN ( SELECT slimity_zoznam.id_rov
           FROM food600.slimity_zoznam)) and nlimitrov_hladiny.pocet<>0  and nlimitrov_hladiny.hodnota<>0;
