SQL语句如何查询首字母大写?

2025-02-23 00:31:19
推荐回答(3个)
回答1:

select * from 表 where 字段 collate chinese_prc_cs_as_ws like 'A%' (查大写 )
select * from 表 where 字段 collate chinese_prc_cs_as_ws like 'a%' (查小写 )
--就是在字段名后加 collate chinese_prc_cs_as_ws

回答2:

SELECT * FROM tablename WHERE (ASCII(SUBSTRING(fieldname, 1, 1)) > 64) AND (ASCII(SUBSTRING(fieldname, 1, 1)) < 91)

回答3:

where substring(field,1,1) between 'A" and 'Z'