通配符字符串选择MySQL

我有一张这样的桌子

|--------------------------------------------|------------------|
|      Column 1                              |     column 2     |
|--------------------------------------------|------------------|
|/fixed/sample_1/                            |         55       |
|--------------------------------------------|------------------|
|/fixed/sample_2/                            |         45       |
|--------------------------------------------|------------------|
|/fixed/sample_3/                            |         30       |
|--------------------------------------------|------------------|

我想使用select语句从第1列中进行选择,并为第2列添加值,即我的结果表为

$.map

有什么办法吗?

谢谢

jsdyhy 回答:通配符字符串选择MySQL

我认为您可以使用substring_index()group by

select substring_index(col1,'/',3) as new_col1,sum(col2)
from t
group by new_col1;
本文链接:https://www.f2er.com/3156997.html

大家都在问