select
*
,(saleCnt/stock *100) as per
,if(p_status in ('release','complete') or (stock - saleCnt) < 1 or p_sale = 'N' , 1, 0) as sale_order
,(select count(*) as cnt from odtOrderApply as ap where ap.ap_pcode = p.code and ap.ap_mid = '' and ap.ap_delete = 'N') as is_apply
from odtProduct as p
where p_view='Y'
and (
select
count(*)
from odtCategory as c
left join odtCategory as c1 on (c.parent_catecode = c1.catecode)
where 1
and c.catecode = p.p_category and
find_in_set('2', c.parent_catecode)>0
) > 0
and (
select
count(*)
from odtCategory as c
left join odtCategory as c1 on (c.parent_catecode = c1.catecode)
where 1
and c.catecode = p.p_category
and (c.cHidden = 'yes' or c1.cHidden = 'yes')
) < 1
order by sale_order asc, per%20desc, pro_idx asc limit 40, 20 |