• yb751 (5/30/2016)


    Eirikur Eiriksson (5/30/2016)


    tmmutsetse (5/30/2016)


    The query that i am using looks like the one below.

    SELECT

    Name,

    Memory,

    Model

    FROM [xxxx].[dbo].[Status]

    where

    active = 1 and

    and name not LIKE '%Caeser'

    and name not like'%Caeser (sql VM)%';

    I do no have so much experience in sql

    What you posted is an attempt to code an undefined logic, not an expression of the logic.

    😎

    Writing the logic in pseudo code is often the best way of expressing it, for the example you have given it would be:

    Select all rows

    where the column Name does not contain "Ceasar" or "Caesar(sql Vm)".

    The problem with this kind of logic is that there is no rule, only cherry picking into the exclusion set which means that all members of the exclusion set must be explicitly stated which also means that the only operator applicable is the equal operator, wild-cards and the like operators don't fit in.

    This kind of queries is easy to write but harder to maintain, in your case the query is simply

    SELECT

    [Name]

    ,[Memory]

    ,[Model}

    FROM [table_name]

    WHERE [Name] NOT IN ('Ceasar','Caesar(sql Vm)');

    LOL...how did I forget to include one of the most obvious example in my list. :crazy:

    Not seeing the forest for the trees;-)

    😎