SELECT `oxv_oxarticles_1_de`.`oxid`, `oxv_oxarticles_1_de`.`oxshopid`, `oxv_oxarticles_1_de`.`oxparentid`, `oxv_oxarticles_1_de`.`oxvarstock`, `oxv_oxarticles_1_de`.`oxvarcount`, `oxv_oxarticles_1_de`.`oxstock`, `oxv_oxarticles_1_de`.`oxstockflag`, `oxv_oxarticles_1_de`.`oxtitle`, `oxv_oxarticles_1_de`.`oxvarselect`, `oxv_oxarticles_1_de`.`oxthumb`, `oxv_oxarticles_1_de`.`oxpic1`, `oxv_oxarticles_1_de`.`oxunitquantity`, `oxv_oxarticles_1_de`.`oxunitname`, `oxv_oxarticles_1_de`.`oxprice`, `oxv_oxarticles_1_de`.`oxskipdiscounts`, `oxv_oxarticles_1_de`.`oxvat`, `oxv_oxarticles_1_de`.`oxtprice`, `oxv_oxarticles_1_de`.`oxweight`, `oxv_oxarticles_1_de`.`oxvarname`, `oxv_oxarticles_1_de`.`oxvarminprice`, `oxv_oxarticles_1_de`.`oxvarmaxprice`, `oxv_oxarticles_1_de`.`oxshortdesc`, `oxv_oxarticles_1_de`.`oxpricec`, `oxv_oxarticles_1_de`.`oxartnum`, `oxv_oxarticles_1_de`.`oxactive`, `oxv_oxarticles_1_de`.`oxicon`, `oxv_oxarticles_1_de`.`oxbundleid`, `oxv_oxarticles_1_de`.`oxfreeshipping`, `oxv_oxarticles_1_de`.`oxnonmaterial`, oxv_oxarticles_1_de.oxtimestamp FROM oxv_oxcategories_1_de
LEFT JOIN oxv_oxobject2category_1 as oc ON oxv_oxcategories_1_de.oxid = oc.oxcatnid
LEFT JOIN oxv_oxarticles_1_de ON oxv_oxarticles_1_de.oxid = oc.oxobjectid
WHERE ( oxv_oxarticles_1_de.oxactive = 1 and oxv_oxarticles_1_de.oxhidden = 0 and ( oxv_oxarticles_1_de.oxstockflag != 2 or ( oxv_oxarticles_1_de.oxstock + oxv_oxarticles_1_de.oxvarstock ) > 0 ) and IF( oxv_oxarticles_1_de.oxvarcount = 0, 1, ( select 1 from oxv_oxarticles_1_de as art where art.oxparentid=oxv_oxarticles_1_de.oxid and art.oxactive = 1 and ( art.oxstockflag != 2 or art.oxstock > 0 ) limit 1 ) ) and ( ( ( select oxobjectrights.oxobjectid from oxobjectrights where oxobjectrights.oxobjectid = oxv_oxarticles_1_de.oxid and oxobjectrights.oxaction = 1 limit 1 ) is null ) ) ) and oxv_oxarticles_1_de.oxparentid = ''
AND oxv_oxcategories_1_de.OXLEFT >= '642'
AND oxv_oxcategories_1_de.OXRIGHT <= '643'
AND oxv_oxcategories_1_de.OXROOTID = 'ad8479f2542a33ba8.19039064'
Group by oxv_oxarticles_1_de.oxid
ORDER BY `oxv_oxarticles_1_de`.`OXARTNUM` asc , oc.oxpos, oc.oxobjectid