Skip to content
Advertisement

SQL : query for multiple conditions with multiple columns

How to query multiple conditions with multiple columns, like AND clause in AND clause.

Example data

The result that I need is without..

  • Country = Japan and ZipCode = 1010
  • Country = Canada and ZipCode = 3030

I try to write SQL like :

but it’s not correct. Any help please ?

Advertisement

Answer

Just use not:

You can expand this out of course:

Note: This constructs will also filter out NULL values. There are none in your sample data and they can both be tweaked to handle them if necessary.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement