I have a table that has about 6 fields. I want to write a SQL statement that will return all records that do not have "England" in the country field, English in the language field & english in the comments field.
What would the sql query be like?
I have a table that has about 6 fields. I want to write a SQL statement that will return all records that do not have "England" in the country field, English in the language field & english in the comments field.
What would the sql query be like?
Start with this and modify as necessary:
SELECT *
FROM SixFieldTable
WHERE Country <> 'England'
AND language <> 'english'
AND comments NOT LIKE '%english%'
Hope this helps.
Are you wanting something like
select * from myTableOfMadness
where country <> 'England'
and language <> 'English'
and comments not like '%english%'
Not sure if you want 'and's or 'or's, or all 'not' comparisons. Your sentence structure is somewhat misleading.
Well, your question depends a lot on what DBMS you're using and what your table set up looks like. This would be one way to do it in MySQL or TSQL:
SELECT *
FROM tbl
WHERE country NOT LIKE '%England%' AND language NOT LIKE '%english%'
AND comments NOT LIKE '%english%';
The way you word your question makes it sound like all these fields could contain a lot of text, in which case the above query would be the way to go. However, more likely than not you'd be looking for exact matches in a real database:
SELECT *
FROM tbl
WHERE country!='England' AND language!='english'
AND comments NOT LIKE '%english%';
Try This
Select * From table
Where Country Not Like '%England%'
And Language Not Like '%English%'
And comments Not Like '%English%'
The above solutions do not appear to account for possible nulls in the columns. The likes of
Where country <> 'England'
will erroneously exclude entries where Country is null, under default SQL Server connection settings.
Instead, you could try using
IsNull(Country, '') <> 'England'
To ignore case:
SELECT *
FROM SixFieldTable
WHERE LOWER(Country) <> 'england' AND
LOWER(language) <> 'english' AND
LOWER(comments) NOT LIKE '%english%'