I’m trying to compare 2 similar columns from 2 tables in SQLite. I wrote this which doesn’t throw an error but also doesn’t return anything and I know it should.
SELECT t1.* from t1, t2 Where t1.col1 Like '%'||t2.col1||'%';
I’m looking for when t2.col1 is embedded inside of t1.col1. Both columns are of type TEXT.
Note: I’m using the C-Interface in C++ with Visual Studio 2010.
Ideas?
Edit:
I’ve played around with pulling a value out of t2.col1 that matches something in t1.col1 and writing something like this,
SELECT t1.* from t1, t2 Where t1.col1 Like '%ValueInT1%';
which works and returns something.
Is there a bug with SQLite when concatenating the ‘%’ character in a like statement or is there a different syntax I should be using? I’m at a loss for why this isn’t working.
I’ve also seen an SQL function called Locate which people use in different Databases to do this kind of check. Does SQLite have a Locate function?
EDIT 2:
I’ve run the first SQL statement in SQLite Administrator with some of my data and it DOES find it. Could there be a simpler problem? There are ‘_’ in the data could that be causing a problem with the like?
(V.V) The answer was that I was joining to the wrong column in the real table. 2 columns had very similar names and I was checking the wrong one.
Thanks for the help.