SELECT
a,SUBSTRING_INDEX(SUBSTRING_INDEX(b,',',help_topic_id+1),',',-1)
AS
num
FROM
mysql.help_topic
,t
WHERE
help_topic_id
<
LENGTH(b)-LENGTH(REPLACE(b,',',''))+1
order
by
num
结果完全就是你要的
先把分类全取出来..并随机排序.. 取排在第一个分类 例如是 西装然后查询的时候 order by (category='西装') desc,category 即可实现要求.
select * from (select * from tablename where A='01' order by B asc) a
union all
select * from (select * from tablename where A='02' order by B desc) a
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)