SQL 截取字段空格之前的数据

MYSQL

SELECT left(city,LOCATE(' ',city)),count(*) FROM `lj_customer` WHERE 1=1 group by left(city,LOCATE(' ',city)) 

SQL

select a,left(a,charindex( ' ',a)) FROM test

 

SELECT left(city,LOCATE(' ',city)),count(*) FROM `lj_customer` WHERE 1=1 group by left(city,LOCATE(' ',city)) 

posted @ 2017-06-30 22:55  张志健  阅读(6913)  评论(0编辑  收藏  举报