SELECT kt.cimke as kategoria_cimke,kt.nev AS kategoria_nev,kt.szint AS kategoria_szint ,s_kt.nev AS szulokategoria_nev,REPLACE(s_kt.cimke,'patron_tonerkereso','toner_kereso') as szulokategoria_cimke, s_kt.szint AS szulokategoria_szint ,REPLACE(IFNULL(r_kt.cimke,s_kt.cimke),'patron_tonerkereso','toner_kereso') AS gyokerkategoria_cimke, IFNULL(r_kt.nev,s_kt.nev) AS gyokerkategoria_nev ,REPLACE(mt.nev,'Jószámítógép','Kolibri') AS marka_nev ,tt.nev AS termek_nev ,REPLACE(tt.cimke,'-','_') AS termek_cimke ,tt.netto,100*CEIL(tt.netto*kt.ksz_armod*.01)-1 AS netto_ar ,CEIL( (1+0.01*tt.afakulcs) * (tt.netto * kt.ksz_armod) * 0.01 )*100 -10 AS eredeti_ar ,CEIL( (1+0.01*tt.afakulcs) * (IF(tt.netto_akcios>0,tt.netto_akcios,tt.netto) * kt.ksz_armod) * 0.01 )*100 -10 AS fizetendo_ar ,tt.netto_akcios>0 AS akcios ,tt.rovidleiras AS rovidleiras ,tt.leiras AS leiras ,tt.specifikacio AS specifikacio ,IFNULL(CONCAT( REPLACE(REPLACE(LOWER(mt.nev),' ','_'),'\'',''),'_', tt.cimke,'-',iut.id,'.jpg'),NULL) AS defaultthumb ,tt.szallitas AS szallitas FROM termekek AS tt JOIN markak AS mt ON tt.marka=mt.id JOIN kategoriak AS kt ON tt.kategoria=kt.id LEFT JOIN kategoriak AS s_kt ON s_kt.az=kt.szulo_az LEFT JOIN kategoriak AS r_kt ON r_kt.az=s_kt.szulo_az LEFT JOIN kepek AS iut ON iut.azonosito=tt.id AND iut.tipus='termekek' AND iut.alapertelmezett='Igen' WHERE 1 AND tt.cimke LIKE '8gb_usb_2_0_dt109_silver' AND tt.szallitas!='nemkaphato' AND tt.szallitas!='hamarosan' AND tt.netto>0 AND tt.engedelyezve='Igen' ORDER BY marka_nev,termek_nev