In a previous question of mine it appears as though my problem is SQLite dependent. I have simplified the problem as follows:
Say I have two tables: table1 as follows
Name | col1
------------------------
Bob | B1
Mary Jane| M1
and table2 as follows:
Name | col2
------------------------------
Bob | B2
Mary | M2
What I would like is to JOIN these together to obtain:
NameA | NameB |col1| col2
-------------------------------------
Bob | Bob | B1 | B2
Mary Jane | Mary | M1 | M2
Using
SELECT tablea.Name as NameA, tableb.Name as NameB, tablea.col1, tableb.col2
FROM table1 as tablea
LEFT JOIN table2 as tableb
ON tablea.Name LIKE tableb.Name
I get as output
NameA NameB col1 col2
1 Bob Bob B1 B2
2 Mary Jane <NA> M1 <NA>
which is what I would expect. Now if I use wildcards as follows:
SELECT tablea.Name as NameA, tableb.Name as NameB, tablea.col1, tableb.col2
FROM table1 as tablea
LEFT JOIN table2 as tableb
ON tablea.Name LIKE '%'+tableb.Name+'%'
I get:
NameA NameB col1 col2
1 Bob <NA> B1 <NA>
2 Mary Jane <NA> M1 <NA>
It doesn't even match Bob's entries?!
Am I missing something? Is this a problem with SQLite
?
For completeness, I'm using the sqldf
function with R
which uses SQLite
.
Aucun commentaire:
Enregistrer un commentaire