数据库读出来的, 那位高人给个详细点的实现方法. TO一楼的大哥: 你说的是ASC排序吗, 我想您应该没弄明白我要实现的效果,
TO二楼的仁兄:可否说得再详细些,再说一遍想要实现的结果,, 用一个DIV模拟SELECT 有几百个关键词同时读出来, 默认排序按首个拼音字母A-Z ,如果我在敲盘上按下B键,那么以B为首个拼音字母的关键词显示到最上面,谢谢谢谢,
TO二楼的仁兄:可否说得再详细些,再说一遍想要实现的结果,, 用一个DIV模拟SELECT 有几百个关键词同时读出来, 默认排序按首个拼音字母A-Z ,如果我在敲盘上按下B键,那么以B为首个拼音字母的关键词显示到最上面,谢谢谢谢,
http://download.csdn.net/source/277492
1:参照ajax关键词自动搜索的方式
2:所有关键词必须在保存时记录拼音首字母
3:检索时按照拼音首字母匹配而不是关键词匹配
2、写 SQL 语句的时候调用该函数create function f_GetPy(@Str nvarchar(400))
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 @t 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
go--测试1
select dbo.f_GetPy('妖怪') as 转换后,dbo.f_GetPy('ab中c国人') as 中国人--测试2
select * from 表 where dbo.f_GetPy(列名)='一串声母'
假设关键词对应的字段为 keyword ,输入的关键词(声母)为 abc
则语法为:select * from table where f_GetPy(keyword) like '%abc%'