. "SELECT"
. " pd.name as name,"
. " p.G_ide as id,"
. " p.model as articul,"
. " pa.`value` as sort,"
. " p.upc as code_1C,"
. " p.status as status,"
. " pts.price as price,"
. " p.market as market,"
. " 'product' as type,"
. " c.category_id as category,"
. " c.skpath as skpath,"
. " (SELECT 1 FROM product WHERE height=0 AND length=0 AND width=0 AND product_id=pts.product_id) as gab,"
. " (SELECT name FROM category_description WHERE category_id=c.category_id AND language_id=2) as category_name,"
. " p1c.data as data_1c"
. " FROM"
. " category c"
. " LEFT JOIN"
. " product_to_category ptc ON (ptc.category_id=c.category_id)"
. " LEFT JOIN"
. " product p ON (ptc.product_id=p.product_id)"
. " LEFT JOIN"
. " product_description pd ON (pd.product_id=p.product_id)"
. " LEFT JOIN"
. " product_to_store pts ON (pts.product_id=p.product_id)"
. " LEFT JOIN"
. " product_additional pa ON (pa.product_id=p.product_id)"
. " LEFT JOIN"
. " product_1c p1c ON p1c.product_id=p.product_id"
. " UNION " //--------------------
. "'' as name,"
. " del.delimiter_id as id,"
. " '' as articul,"
. " '' as sort,"
. " '' as code_1C,"
. " '' as status,"
. " '' as price,"
. " '' as market,"
. " 'delim' as type,"
. " '' as category,"
. " '' as skpath,"
. " '' as gab,"
. " '' as category_name,"
. " '' as data_1c"
. " FROM"
. " delimiter del"
. " LEFT JOIN"
. " delimiter_description deld ON (del.delimiter_id = deld.delimiter_id) "
. " LEFT JOIN "
. " delimiter_to_category d2c ON (del.delimiter_id = d2c.delimiter_id) "
. " LEFT JOIN "
. " category dc ON (dc.category_id = d2c.category) "
. " UNION " //--------------------
. " ccd.name as name, "
. " cc.category_id as id, "
. " '' as articul, "
. " '' as sort, "
. " '' as code_1C, "
. " '' as status, "
. " '' as price, "
. " '' as market, "
. " cctc.type as type, "
. " '' as category, "
. " '' as skpath, "
. " '' as gab, "
. " '' as category_name, "
. " '' as data_1c "
. " FROM "
. " category cc "
. " LEFT JOIN "
. " category_description ccd ON (ccd.category_id = cc.category_id) "
. " LEFT JOIN "
. " category_to_category cctc ON (cctc.to = cc.category_id) "
. " WHERE pa.`key`=concat('sort_',c.category_id) AND pd.language_id=2 AND cc.parent_id=".(int)$category_id." AND dc.parent_id=".(int)$category_id." AND c.parent_id=" . (int)$category_id;
coбственно вот. ругается что неправильный синтаксис в районе UNION '' AS name, del.delimiter_id AS id
но неверного синтаксиса в упор не вижу