主题:  请问一个SQL问题,如何从数据库中提取出......

浮尘

职务:普通成员
等级:3
金币:7.0
发贴:1258
#12004/8/29 23:32:53
请问一个SQL问题,如何从数据库中提取出姓氏是以汉语拼音b开始的人的名字?



蓝鲸

职务:版主
等级:5
金币:42.1
发贴:2614
#22004/8/30 8:54:33
我也正研究这个问题,但只有点思路,还没行动去做。
就是用拼间输入法代码做成数据库,然后在人员库中增加拼音码这个字段,在每次存诸中,把输入法中的拼音代码存诸在这个字段中,这样就可以搜索了。
只是点提示,做起来还有很多问题。


非常大鱼

吃鱼专家

职务:普通成员
等级:6
金币:11.0
发贴:5312
#32004/8/30 10:19:26
SQL有这种功能吗?不过好像可以按拼音来进行排序



阿好

职务:普通成员
等级:1
金币:0.0
发贴:9
#42004/8/31 15:04:59
如何按姓氏笔画排序:

Select * From TableNameOrder By CustomerName Collate Chinese_PRC_Stroke_ci_as



蓝鲸

职务:版主
等级:5
金币:42.1
发贴:2614
#52004/8/31 16:28:42
不知SQL有没有这功能,上面的虽然实现了排序,但好象不能按特定字母给出个搜索集合出来,如给出所有ch开头的名字,不符合的则不显示。


非常大鱼

缺缺

职务:管理员
等级:8
金币:41.0
发贴:9620
#62004/8/31 16:54:08
我想SQL应该没有这功能吧.需要另外写函数

在别的地方看到这样一段代码,没有测试.
Function GetSQLString(ByVal Index)
Dim 
Ascii(27)
Dim Line,Row,Char,strTemp
Dim i,j
Ascii(1) = "45217,45252"
Ascii(2) = "45253,45310;45485,45566;45731,45760"
Ascii(3) = "45761,45822;45985,46078;46241,46317"
Ascii(4) = "46318,46334;46497,46590;46753,46825"
Ascii(5) = "46826,46846;47009,47009"
Ascii(6) = "47010,47102;47265,47296"
Ascii(7) = "47297,47358;47521,47613"
Ascii(8) = "47614,47614;47777,47870;48033,48118"
Ascii(9) = ""
Ascii(10) = "48119,48126;48289,48382;48545,48638;48801,48894;49057,49061"
Ascii(11) = "49062,49150;49313,49323"
Ascii(12) = "49324,49406;49569,49662;49825,49895"
Ascii(13) = "49896,49918;50081,50174;50337,50370"
Ascii(14) = "50371,50430;50593,50613"
Ascii(15) = "50614,50621"
Ascii(16) = "50622,50686;50849,50905"
Ascii(17) = "50906,50942;51105,51198;51361,51386"
Ascii(18) = "51387,51445"
Ascii(19) = "51446,51454;51617,51710;51873,51966;52129,52217"
Ascii(20) = "52218,52222;52385,52478;52641,52697"
Ascii(21) = ""
Ascii(22) = ""
Ascii(23) = "52698,52734;52897,52979"
Ascii(24) = "52980,52990;53153,53246;53665,53688"
Ascii(25) = "53689,53758;53921,54014;54177,54270;54433,54480"
Ascii(26) = "54481,54526;54689,54782;54945,55038;55201,55289"
If Index = "@" Then	
GetSQLString = "SELECT * FROM Article WHERE SUBSTRING(REPLACE(REPLACE(Title,'“',''),'《',''),1,1) IN ('0','1','2','3','4','5','6','7','8','9') ORDER BY Title"
Exit Function
End If
GetSQLString = "SELECT * FROM Article WHERE SUBSTRING(REPLACE(REPLACE(Title,'“',''),'《',''),1,1) IN (" & "'" & Index & "'"strTemp = Ascii(Asc(UCase(Index)) - 64)
If strTemp <> "" Then
Line = Split(strTemp, ";")
For i = 0 To UBound(Line)
Row = Split(Line(i), ",")		
For j = Row(0) To Row(1)			
Char = Chr(j - 65536)			
GetSQLString = GetSQLString & ",'" & Char & "'"		
Next	
Next
End If
GetSQLString = GetSQLString & ") ORDER BY Title"
End Function
Dim Connection,Recordset
Set Connection = Server.CreateObject("ADODB.Connection")
Set Recordset = Server.CreateObject("ADODB.Recordset")
Connection.Open "......"
Recordset.Open GetSQLString("a"),Connection... ...


编辑历史:[此帖最近一次被 allinhands 编辑过(编辑时间:2004-08-31 17:05:39)]


浮尘

职务:普通成员
等级:3
金币:7.0
发贴:1258
#72004/9/1 23:13:59
多谢各位,看起来这还是一个不太好弄的问题呀。还在研究中,希望大家一起研究吧,并共享。