答案 0 :(得分:1)
使用字符串函数几乎可以使用以下
来实现select a.*
from demo a
join (select value,substring_index(name,'_',2) company_name
from demo
where substring_index(name,'_',-1) = 'name'
) b on substring_index(a.name,'_',2) = b.company_name
order by b.value asc,substring_index(a.name,'_',2) asc,substring_index(name,'_',-1) desc
答案 1 :(得分:1)
SELECT a.* FROM css_01 a LEFT JOIN (SELECT substring_index(name, '_', 2) as meta_like_key, value FROM css_01 wpm1 WHERE name like "company_%_name" ) b ON substring_index(a.name, '_', 2) = b.meta_like_key ORDER BY b.value ASC ,substring_index(a.name,'_',2) asc,a.name desc