Marshall said:
My point about using like without wildcards (above) is that
the right side operand must be verified as not containing
any wildcards, because Like will use them if they are there.
That is a good point. Here's a demo of how the row containing the
wildcard character '%' differs on the right side to that of the left
(if they were treated the same we'd get the same results as for the
equi-join):
Sub LikeIt()
Dim cat As Object
Set cat = CreateObject("ADOX.Catalog")
With cat
.Create _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\DropMe.mdb;"
With .ActiveConnection
..Execute _
"CREATE TABLE Test1 (" & _
" test_col NVARCHAR(3) NOT NULL);"
..Execute _
"INSERT INTO Test1 (test_col) VALUES ('ABC');"
..Execute _
"INSERT INTO Test1 (test_col) VALUES ('OPQ');"
..Execute _
"INSERT INTO Test1 (test_col) VALUES ('XYZ');"
..Execute _
"INSERT INTO Test1 (test_col) VALUES ('%');"
Dim rs As Object
Set rs = .Execute( _
" SELECT T1.test_col, T2.test_col " & _
" FROM Test1 AS T1 INNER JOIN Test1 AS T2" & _
" ON T1.test_col = T2.test_col " & _
" ORDER BY T2.test_col, T1.test_col; ")
MsgBox "EQUI-JOIN:" & vbCr & vbCr & rs.GetString
rs.Close
Set rs = .Execute( _
" SELECT T1.test_col, T2.test_col " & _
" FROM Test1 AS T1 INNER JOIN Test1 AS T2" & _
" ON T1.test_col LIKE T2.test_col " & _
" ORDER BY T2.test_col, T1.test_col; ")
MsgBox "LIKE JOIN:" & vbCr & vbCr & rs.GetString
rs.Close
End With
Set .ActiveConnection = Nothing
End With
End Sub
Jamie.
--