7,714
社区成员
发帖
与我相关
我的任务
分享
SELECT tbl_a.id, tbl_a.name,concateColumn("tbl_b","property",id)
FROM tbl_a;
id name Expr1002
1 张三 房子 ;车子 ;票子;
2 李四
Public Function concateColumn(sTable As String, sCol As String, iID As Long)
Dim rs As New ADODB.Recordset
Dim sSQL As String
Dim sResult As String
sResult = ""
sSQL = "select " & sCol & " from " & sTable & " where id=" & iID
rs.Open sSQL, CurrentProject.Connection
Do While Not rs.EOF
sResult = sResult & rs.Fields(0).Value & ";"
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
concateColumn = sResult
End Function