我有两张桌子。表1的product_id是表2的FK。
在SQLAlchemy中,我如何从表1中选择特定的user_id的product_id,并从表2中检索其product_description?
Table 1
user_id, product_id
1 2
2 5
3 2
Table 2
product_id, product_description
1 some product_description
2 some product_description
3 some product_description
4 some product_description
答案 0 :(得分:0)
If (Not (IsNull(path))) Then
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" & path & ";"
Set rs = New ADODB.Recordset
rs.Open "BCIImport", cn, adOpenKeyset, adLockOptimistic, adCmdTable
On Error Resume Next
Do While Len(Range("B" & r).Formula) > 0
With rs
If Not rs.BOF Then
rs.MoveFirst
End If
If (Range("B" & r).Interior.Color = RGB(0, 255, 255)) Then
.AddNew
.Fields("LocationID") = Range("B" & r).Value
.Fields("Priority1") = Range("C" & r).Value
.Fields("Priority2") = Range("D" & r).Value
.Update
End If
End With
r = r + 1 'advances to next row
Loop
rs.Close
cn.Close
Set rs = Nothing
Set cn = Nothing
End If