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       c20   

    table 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

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -