首页 > 【MySQL】求一个SQL语句的优化

【MySQL】求一个SQL语句的优化

select *
from yq_product
where instr(concat(title,',',metakey,',',metadesc,',',cat_name,',',brand_name), '品')
order by instr(concat(title,',',metakey,',',metadesc,',',cat_name,',',brand_name), '品')

就是 instr(concat(title,',',metakey,',',metadesc,',',cat_name,',',brand_name), '品') 这一句,有办法不重复吗?

试过这样不行:

select *, instr(concat(title,',',metakey,',',metadesc,',',cat_name,',',brand_name), '品') as search
from yq_product
where search>0
order by search

加个变量

where @st:=instr(...) order by @st;
【热门文章】
【热门文章】