当前位置:首页 » 编程语言 » sql汉字首字母

sql汉字首字母

发布时间: 2022-06-07 07:04:23

sql语句提取出中文的拼音首字母

那我估计不行。
只能把汉字的拼音,存在另一个字段。
当然你也写个对照表。
如:
张 zhang
这样,你插入时,也把zhang插入到拼音字段里(你自己定义的varchar)。
张三 zhang;san //用分号来分隔
做查询时把zhang;san 用数组来存储,接着读取第一个下标的首字母。
(jsp、asp:split() 就行,php没学过 )

Ⅱ sql 查询不重复并且按照汉字首字母排序

select distinct 联赛分类 from inf order by 联赛分类
这样不就可以了,默认本来就是根据首个字符排序的,中文就是根据字母排序的

Ⅲ sql 如何按照汉字的拼音的首字母顺序来查询!~!~

字段1内的数据是汉字
最后在where查询语句的后面加上
order by 字段1 就可以了
补充:
order by 是排序
order by 字段1 desc 为倒序

Ⅳ sql中怎么根据汉字的拼音首字母查询

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
-- SQLServer:
---测试数据---
if object_id('[pactinfo]') is not null drop table [pactinfo]
go
create table [pactinfo]([ID] int,[pactname] varchar(4))
insert [pactinfo]
select 1,'正常' union all
select 2,'中国' union all
select 3,'做饭' union all
select 4,'加发'

---引用前辈们的一个函数---
create function f_GetPy(@str nvarchar(4000))
returns nvarchar(4000)
as
begin
declare @strlen int,@re nvarchar(4000)
declare @t table(chr nchar(1) collate Chinese_PRC_CI_AS,letter nchar(1))
insert into @t(chr,letter)
select '吖 ', 'A ' union all select '八 ', 'B ' union all
select '嚓 ', 'C ' union all select '咑 ', 'D ' union all
select '妸 ', 'E ' union all select '发 ', 'F ' union all
select '旮 ', 'G ' union all select '铪 ', 'H ' union all
select '丌 ', 'J ' union all select '咔 ', 'K ' union all
select '垃 ', 'L ' union all select '呒 ', 'M ' union all
select '拏 ', 'N ' union all select '噢 ', 'O ' union all
select '妑 ', 'P ' union all select '七 ', 'Q ' union all
select '呥 ', 'R ' union all select '仨 ', 'S ' union all
select '他 ', 'T ' union all select '屲 ', 'W ' union all
select '夕 ', 'X ' union all select '丫 ', 'Y ' union all
select '帀 ', 'Z '
select @strlen=len(@str),@re= ' '
while @strlen> 0
begin
select top 1 @re=letter+@re,@strlen=@strlen-1
from @t a where chr <=substring(@str,@strlen,1)
order by chr desc
if @@rowcount=0
select @re=substring(@str,@strlen,1)+@re,@strlen=@strlen-1
end
return(@re)
end

---查询---
select
*
from
[pactinfo]
where
left(dbo.f_GetPy(pactname),1)='Z'

---结果---
ID pactname
----------- --------
1 正常
2 中国
3 做饭

(所影响的行数为 3 行)

Ⅳ SQL Server 如何提取汉字首字母

这个我以前写过, 要用 C# 来写, 然后 发布到 SQL Server 上面去。

你要是会 C# 的话, 倒可以尝试尝试, 否则就不必下载附件了。


那个项目还引用了 Microsoft.International.Converters.PinYinConverter 这个类库。

你可能还要去微软网站找来下载一下。

或者用其他的算法, 通过汉字, 返回拼音的。


Ⅵ SQL获取汉字首字母方法

先把汉字转成拼音,然后取第一个字母,转拼音可参考http://wenku..com/link?url=_EMDG0__Pt5zouVxBXciJ__,取第一个字母=left(字符串,1)

热点内容
ssrpc端怎么删除服务器 发布:2024-05-16 13:53:14 浏览:235
如何配置gdc服务器 发布:2024-05-16 13:53:12 浏览:984
安卓系统阿尔法编译器 发布:2024-05-16 13:51:49 浏览:989
建行支付密码器怎么用 发布:2024-05-16 13:50:19 浏览:985
智能手环如何配置 发布:2024-05-16 13:48:00 浏览:484
shell脚本vim 发布:2024-05-16 13:43:15 浏览:302
征途修改脚本 发布:2024-05-16 13:42:31 浏览:409
xp共享打印机拒绝访问 发布:2024-05-16 13:41:31 浏览:814
常州php招聘 发布:2024-05-16 13:14:52 浏览:590
十二万左右捷达车配置质量怎么样 发布:2024-05-16 12:17:00 浏览:598