我有这样的字符串:
PRODUCT_ID =
CATEGORY_ID = 340
flypage =
页=
PAGE_TITLE =
show_page_title = 1
pageclass_sfx =
menu_image = -1
固定= 0
如何提取category_id?我试图从字段中获取数值,但我得到340110而不是340
答案 0 :(得分:1)
如果您要从上面的模式中提取值,看起来它们与\n
分开,您可以获得值
mysql> select substring_index(substring_index('product_id=
category_id=340
flypage=
page=
page_title=
show_page_title=1
pageclass_sfx=
menu_image=-1
secure=0','category_id=','-1'),'\n',1) as val;
+-----+
| val |
+-----+
| 340 |
+-----+
1 row in set (0.00 sec)
您可以在查询中使用
select substring_index(substring_index(col_name,'category_id=','-1'),'\n',1) as val;