请问如何按拼音模糊查找?
系统用ASP+SQL SERVER2000,请问如何实现拼音的模糊查找?
比如查询条件输入 "W ",则所有姓 "王 ", "汪 "等以W开始的人都被检索出来呢
姓名字段名假设叫NAME,望赐教!
------解决方案--------------------GBK和Unicode的是按拼音顺序排列的,可以用以下办法,假设输入为chrPY=“A”
select case chrPY
case "A " strSQL= "@=&HB0A1 and @ <=&HB0C4 "
case "B " strSQL= "@> =&HB0C5 and @ <=&HB2C0 "
.
.
case else strSQL= "1=2 " '不是拼音则不查询
end select
strSQL=replace(strSQL, "@ ", "asc(left(字段名,1)) ") '注意不是ascw
strSQL= "select * from 字段名 where " & strSQL
=======================================
下面是拼音和汉字的对应关系,直接考上来,我就不改写了
Select Case true
case lngGBK> =&HB0A1 and lngGBK <=&HB0C4
strPY= "A "
case lngGBK> =&HB0C5 and lngGBK <=&HB2C0
strPY= "B "
case lngGBK> =&HB2C1 and lngGBK <=&HB2C0
strPY= "C "
case lngGBK> =&HB4EE and lngGBK <=&HB6E9
strPY= "D "
case lngGBK> =&HB6EA and lngGBK <=&HB7A1
strPY= "E "
case lngGBK> =&HB7A2 and lngGBK <=&HB8C0
strPY= "F "
case lngGBK> =&HB8C1 and lngGBK <=&HB9FD
strPY= "G "
case lngGBK> =&HB9EE and lngGBK <=&HBBF6
strPY= "H "
case lngGBK> =&HBBF7 and lngGBK <=&HBFA5
strPY= "J "
case lngGBK> =&HBFA6 and lngGBK <=&HC0AB
strPY= "K "
case lngGBK> =&HC0AC and lngGBK <=&HC2E7
strPY= "L "
case lngGBK> =&HC2E8 and lngGBK <=&HC4C2
strPY= "M "
case lngGBK> =&HC4C3 and lngGBK <=&HC5B5
strPY= "N "
case lngGBK> =&HC5B6 and lngGBK <=&HC5BD
strPY= "O "
case lngGBK> =&HC5BE and lngGBK <=&HC6D9
strPY= "P "
case lngGBK> =&HC6DA and lngGBK <=&HC8BA
strPY= "Q "
case lngGBK> =&HC8BB and lngGBK <=&HC8F5
strPY= "R "
case lngGBK> =&HC8F6 and lngGBK <=&HCBF9
strPY= "S "
case lngGBK> =&HCBFA and lngGBK <=&HCDD9
strPY= "T "
case lngGBK> =&HCDDA and lngGBK <=&HCEF3
strPY= "W "
case lngGBK> =&HCEF4 and lngGBK <=&HD1B8
strPY= "X "
case lngGBK> =&HD1B9 and lngGBK <=&HD4D0
strPY= "Y "
case lngGBK> =&HD4D1 and lngGBK <=&HD7FD
strPY= "Z "
End Select