【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
阅读 3.5k
1 个回答

加个变量

where @st:=instr(...) order by @st;
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏