Identical where conditions giving different results

47 Views Asked by At

Why are these two queries not giving the same result?

PROC SQL;
CREATE TABLE NAME_MATCHING AS
SELECT t1.\*
FROM WORK.table1 t1
WHERE t1.names contains name1 
   OR t1.names contains name2 
   OR t1.names contains name3
   OR t1.names contains name4
   OR ...
 ;
QUIT;

And

PROC SQL;
CREATE TABLE NAME_MATCHING AS
SELECT t1.\*, t2.\*
FROM WORK.table1 t1 , WORK.table2 t2
WHERE t1.names contains t2.names
 ;

QUIT;

Where t2.names is just a column with name1, name2, name3, etc...

I tried using the index function instead of "contains", but it still gives different results, and I dont know what I'm not getting, maybe its something obvious.

1

There are 1 best solutions below

1
Richard On

Try your second query with

where
t1.names contains trim(t2.names)