输入一个拼音,就可以将数据库中的字段中第一个汉字的拼音相同,全部查询出来

jag1976 2005-10-25 02:30:55
这个是否可以直接写SQL语句实现?
...全文
164 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
jag1976 2005-10-25
  • 打赏
  • 举报
回复
我在网上查到了,在数据库中创建一个函数,而后就可以SQL语句了
谢谢大家

create function fGetPy(@Str varchar(500)='')
returns varchar(500)
as
begin
declare @strlen int,@return varchar(500),@ii int
declare @n int,@c char(1),@chn nchar(1)

select @strlen=len(@str),@return='',@ii=0
set @ii=0
while @ii<@strlen
begin
select @ii=@ii+1,@n=63,@chn=substring(@str,@ii,1)
if @chn>'z'
select @n = @n +1
,@c = case chn when @chn then char(@n) else @c end
from(
select top 27 * from (
select chn = '吖'
union all select '八'
union all select '嚓'
union all select '咑'
union all select '妸'
union all select '发'
union all select '旮'
union all select '铪'
union all select '丌' --because have no 'i'
union all select '丌'
union all select '咔'
union all select '垃'
union all select '嘸'
union all select '拏'
union all select '噢'
union all select '妑'
union all select '七'
union all select '呥'
union all select '仨'
union all select '他'
union all select '屲' --no 'u'
union all select '屲' --no 'v'
union all select '屲'
union all select '夕'
union all select '丫'
union all select '帀'
union all select @chn) as a
order by chn COLLATE Chinese_PRC_CI_AS
) as b
else set @c='a'
set @return=@return+@c
end
return(@return)
end
chenyulin 2005-10-25
  • 打赏
  • 举报
回复
有汉字拼音对照表的数据库就能了
teli_eurydice 2005-10-25
  • 打赏
  • 举报
回复
需要设置拼音字段
bohut 2005-10-25
  • 打赏
  • 举报
回复
http://blog.csdn.net/bohut/archive/2004/10/29/157911.aspx
alen_ghl 2005-10-25
  • 打赏
  • 举报
回复
自己在数据库里加上需要的字段
kenskens 2005-10-25
  • 打赏
  • 举报
回复
顶一下
goodboyws 2005-10-25
  • 打赏
  • 举报
回复
从网上下载一个汉字拼音对照表,添加到数据库里去
bohut 2005-10-25
  • 打赏
  • 举报
回复
需要增加一个字段用来存该字段的拼音,查询时查拼音
kugou123 2005-10-25
  • 打赏
  • 举报
回复
你的数据库应该有个拼音对照表之类的吧?
kugou123 2005-10-25
  • 打赏
  • 举报
回复
select * from A where B='……'
nkwesley 2005-10-25
  • 打赏
  • 举报
回复
这个不知道行不行

除非自己加索引

16,551

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Creator Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧