davvv davvv - 2 years ago 79
SQL Question

Display all results unless a particular phrase exists in one column

In order to archive a database row I am inserting the phrase "Yes" into a column


UPDATE fault SET faultArc=@faultArc WHERE faultID = {0}

This means when the row has a "Yes" it is not to be displayed on the

I have tried (from this SO article here):

SELECT * FROM fault WHERE faultArc NOT Like '%Yes%'

The above does work, but it hides all rows even without "Yes" in column

How can I get round this? Display all data, except any data with a "Yes" in the

Answer Source

Like will filter out the nulls. You can include nulls result by adding condition in OR:

select *
from fault
where faultArc not like '%Yes%'
    or faultArc is null;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download