【发布时间】:2015-03-06 11:08:10
【问题描述】:
我在 mysql 表中有存储页面路径的路径字段。
页面 id 末尾有 33、31、121 ...
如何编写查询以仅获取 ID?
Path
-----
trending-architectures/architecture_detail_page/31
trending-architectures/architecture_detail_page/33
trending-architectures/architecture_detail_page/33
trending-architectures/architecture_detail_page/33
trending-architectures/architecture_detail_page/33
【问题讨论】:
-
在 PHP 中你可以使用
preg_match_all------------------------preg_match_all('!\d+!', $str, $matches); print_r($matches);或者你甚至可以使用preg_match_all("/[^0-9]/","",$str,$matches); print_r($matches); -
我必须在mysql的SELECT语句中这样做。
-
所有的字符串都是相同的模式?即 2
/和/之后的最后一个值是一个数字? -
我找不到一个单一的查询解决方案。stackoverflow.com/questions/978147/…查看这个链接。它可以帮助你...
-
我能知道一件事吗...使用 PHP,您只需一步即可轻松完成,对吧.. 为什么要为此使用 MySQL ????