substring_index(某个字段,以其分割,第几个分割点之前的值);

+---------------------------------------------------------+
| SUBSTRING_INDEX('www.mysql.com', '.', 2)                |
+---------------------------------------------------------+
| www.mysql                                               |
+---------------------------------------------------------+
在做前台分类列表的功能,可以很好的使用到了这个函数。

例:
 $sql="SELECT substring_index(cid, ',',1) as `key`,count(*) as num from ".V_PROMOS_COMMODITY." where city='$city_name'  GROUP BY  `key`";
查询一个表在某个城市下,每个父id有多少数据。//cid字段为(83,141)其中83为父类

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-23
  • 2022-12-23
猜你喜欢
  • 2021-07-31
  • 2022-01-17
  • 2021-09-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案