Search code examples
mysqlsql-likein-operatornot-operator

MySQL - NOT IN LIKE


How can I, in mysql, check if a value is inside a number of fields in another table?

Something like

SELECT * FROM table WHERE concat('%',value,'%') NOT LIKE IN(SELECT field FROM anothertable)

But I don't think that's quite right, is it?


Solution

  • The following query should do it.

    SELECT DISTINCT t.* 
    FROM   table t, 
           anothertable a 
    WHERE  a.field NOT LIKE Concat('%', t.`value`, '%');