category-list SELECT `ref`.`id`, `ref`.`grp`, `ref`.`product`, `ref`.`product_n`, REPLACE(`product`.`product`,'_',' ') AS `product_code`, `ref`.`product_code` AS `product_url`, if (3 = 1, concat('../../fibre_be/.p_uploads/','product_images/','s/', `ref`.`gcode`, '_1245', right(ref.group_image, 4) ), if (3 = 2, concat('../../fibre_be/.p_uploads/','product_images/','s/', `ref`.`id`,'/', `ref`.`product_code`, '_1245',right(ref.main_image, 4) ), if (3 = 3, if (length(ref.main_image > 5), concat('../../fibre_be/.p_uploads/','product_images/','s/', `ref`.`id`,'/', `ref`.`product_code`, '_1245',right(ref.main_image, 4) ), concat('../../fibre_be/.p_uploads/','product_images/','s/', `ref`.`gcode`, '_1245', right(ref.group_image, 4) )), '' ) ) ) as main_image, v1.name as `v_01`,`product_group`.`v_01` AS `tagV_01`, v2.name as `v_02`,`product_group`.`v_02` AS `tagV_02`, v3.name as `v_03`,`product_group`.`v_03` AS `tagV_03`, v4.name as `v_04`,`product_group`.`v_04` AS `tagV_04`, v5.name as `v_05`,`product_group`.`v_05` AS `tagV_05`, v6.name as `v_06`,`product_group`.`v_06` AS `tagV_06`, v7.name as `v_07`,`product_group`.`v_07` AS `tagV_07`, v8.name as `v_08`,`product_group`.`v_08` AS `tagV_08`, v9.name as `v_09`,`product_group`.`v_09` AS `tagV_09`, v10.name as `v_10`,`product_group`.`v_10` AS `tagV_10`, (SELECT `price_min_qty` FROM `multiple_price` WHERE `multiple_price`.`code`=`ref`.`id` ORDER BY `price_min_qty` DESC LIMIT 1) AS `last_price`, MATCH(`ref`.`product_code`) AGAINST('' IN BOOLEAN MODE) as r1, MATCH(site_search.keywords) AGAINST('' IN BOOLEAN MODE) as r2 FROM `ref` left join product on product.id = ref.product LEFT JOIN `product_group` ON `product_group`.`id`=`ref`.`s_grp` left join varient_view v1 on v1.code=ref.v_01 and v1.s_grp = ref.s_grp and v1.grp = ref.grp left join varient_view v2 on v2.code=ref.v_02 and v2.s_grp = ref.s_grp and v2.grp = ref.grp left join varient_view v3 on v3.code=ref.v_03 and v3.s_grp = ref.s_grp and v3.grp = ref.grp left join varient_view v4 on v4.code=ref.v_04 and v4.s_grp = ref.s_grp and v4.grp = ref.grp left join varient_view v5 on v5.code=ref.v_05 and v5.s_grp = ref.s_grp and v5.grp = ref.grp left join varient_view v6 on v6.code=ref.v_06 and v6.s_grp = ref.s_grp and v6.grp = ref.grp left join varient_view v7 on v7.code=ref.v_07 and v7.s_grp = ref.s_grp and v7.grp = ref.grp left join varient_view v8 on v8.code=ref.v_08 and v8.s_grp = ref.s_grp and v8.grp = ref.grp left join varient_view v9 on v9.code=ref.v_09 and v8.s_grp = ref.s_grp and v9.grp = ref.grp left join varient_view v10 on v10.code=ref.v_10 and v10.s_grp = ref.s_grp and v10.grp = ref.grp left join site_search on site_search.code = ref.id WHERE `ref`.`grp`='101' AND `ref`.`product`=121 AND `ref`.`product_type`=0 AND `ref`.`status`=1 AND `ref`.`publish` =1