I want to exclude a record in my table but it is not working logically. Here is my Weapons
table:
Name / DPS / Style
Noxious Bow / 1000 / Range
Chaotic Staff / 800 / Magic
Armadyl Crossbow / 750 / Range
Saradomin Godsword / 600 / Melee
Dragon Longsword / 600 / Magic
Dragon Longsword / 550 / Melee
Elder Shortbow / 500 / Range
What I'm trying to do is exclude the record Dragon Longsword
which has a Style
of Melee
.
Here is what I tried:
SELECT *
FROM Weapons
Where Name!='Dragon Longsword' AND Style!='Melee';
What is happening is that it is not displaying any record that contains Dragon Longsword
or Melee
. I want it to not display only the following record:
Dragon Longsword / 550 / Melee
Logically, what you want is:
not (name == 'Dragon Longsword' and Style == 'Melee')
Applying simple boolean logic (De Morgan's laws, thank you @Rocket), this can be translated into:
name != 'Dragon Longsword' or Style != 'Melee'
So the correct query would need an OR
, not an AND
, as unintuitive as it may seem:
SELECT *
FROM Weapons
Where Name!='Dragon Longsword' OR Style!='Melee';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With