素材牛VIP会员
【MySQL】求一个SQL语句的优化
 13***64  分类:SQL代码  人气:807  回帖:1  发布于6年前 收藏
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

讨论这个帖子(1)垃圾回帖将一律封号处理……

Lv5 码农
wg***ge 页面重构设计 6年前#1

加个变量

where @st:=instr(...) order by @st;
 文明上网,理性发言!   😉 阿里云幸运券,戳我领取