當前位置:首頁 » 編程語言 » 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)

熱點內容
高中ftp 發布:2024-04-30 01:51:48 瀏覽:872
林秋楠手機的密碼是多少 發布:2024-04-30 01:46:31 瀏覽:275
python靜態類方法 發布:2024-04-30 01:30:28 瀏覽:461
zblogphpasp 發布:2024-04-30 01:27:35 瀏覽:136
宏程序自動編程軟體 發布:2024-04-30 01:15:01 瀏覽:416
vs添加編譯選項 發布:2024-04-30 01:06:10 瀏覽:613
編程紅碼 發布:2024-04-30 01:04:49 瀏覽:910
給數組賦值java 發布:2024-04-30 01:04:37 瀏覽:498
我的世界jave版如何開伺服器 發布:2024-04-30 01:02:34 瀏覽:901
safari清除緩存ipad 發布:2024-04-30 00:47:24 瀏覽:523