sql - MySQL Not like query -
i compare table1 , table2 specified column string , want return unmatched records table1.
it works great when use other way 'like' , return matching result.
but looking unmatched records.
here sample tables
table 1 ---------------------------------- no. designid 1 c12345 2 c16 3 c20table 2 ---------------------- no. designoption 1 online-c12345-print 2 online-c16-proof
$db->fetchallcolumn(select distinct(a.designid) table1 a, table2 b b.designoption not concat('%', a.designid, '%')); with join example
$db->fetchallcolumn(select distinct(a.designid) table1 inner join table2 b on b.designoption not concat('%', a.designid, '%')); expected result: c20
instead records table1
any appreciated.
assuming query works, use outer join:
select distinct a.designid table1 left join table2 b on b.designoption concat('%', a.designid, '%') b.designoption null; note distinct not function. sql operator select distinct. don't use parentheses -- unless have reason doing so.
Comments
Post a Comment