'LIKE' clause with 'AND' operator in SQL Server 2012

I have exactly the same requirement as in this thread. How to use JOIN LIKE with AND Operator in SQL Server?

I have been clueless despite searching the net for hours.

  • SQL Server 2012: Login to PC-NAME\SQLEXPRESS works, but not to local/(local)
  • How to store a dynamic SQL result in a variable in T-SQL?
  • deploy SQL Server Express database with desktop app?
  • sql convert date format not working
  • How to implement a schema with primary and foreign keys
  • Query a website in SSIS
  • I have a table ‘Filter’ with column ‘Value’ and 2 records in it as ‘Value1’ and ‘Value2’ as varchar values.

    Select * From MasterTable
    Inner Join Filter ON MasterTable.Name LIKE '%' + Filter.Value + '%'

    This query means:

    Select * From MasterTable
    Where MasterTable.Name LIKE '%Value1%' OR MasterTable.Name LIKE '%Value2%'

    Now how can I change JOIN LIKE that means AND not OR? Something like:

    Select * From MasterTable
    Where MasterTable.Name LIKE '%Value1%' AND MasterTable.Name LIKE '%Value2%'

    Can anyone show me a way out.

  • SQL Server is not showing in Visual Studio
  • Finding Page Number of specific record
  • SQL: Ensuring all rows are checked against a set of rows
  • SQL Server 2008: Count Number of Keys In Multiple Date Ranges
  • SQL - Clone a record and its descendants
  • How to fix reversed arabic characters mixed with english in SQL server
  • One Solution collect form web for “'LIKE' clause with 'AND' operator in SQL Server 2012”

    You can generally rewrite a “X matches all Y” query as “X does not have any Y that do not match” – or in other words a NOT EXISTS query for the inverse of Y.

    select *
    from MasterTable
    where not exists (
        select 1
        from Filter
        where MasterTable.Name not like '%' + Filter.Value + '%'
    MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.