1. 程式人生 > >SQL 截取字段空格之前的數據

SQL 截取字段空格之前的數據

from width dot ken key custom dmi pre targe

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))

SQL 截取字段空格之前的數據