select 地名,路径,left(路径,InstrRev(路径,"-")) as 结果 from tbname
为你需要的结果,也可写为:
select 地名,路径,Replace(路径,地名,"") as 结果 from tbname 作者: aslxt 时间: 2011-5-20 16:08
查询的方法,基于地名和要去掉的那部分完全相同:
SELECT 表1.地名, 表1.路径, Left([路径],Len([路径])-Len([地名])) AS 表达式1 FROM 表1作者: lgh00289 时间: 2011-5-20 16:24
谢谢todaynew 和aslxt 作者: aslxt 时间: 2011-5-20 16:42
替换方法
Private Sub Command0_Click()
Dim rec As ADODB.Recordset
Dim i As Long
Set rec = New ADODB.Recordset
rec.Open "select * from 表1", CurrentProject.Connection, adOpenStatic, adLockOptimistic
For i = 1 To rec.RecordCount
rec.Fields("路径") = Replace(rec.Fields("路径"), rec.Fields("地名"), "")
rec.Update
rec.MoveNext
Next i
End Sub 作者: lgh00289 时间: 2011-5-21 09:03
TKS aslxt