MySQL Forums
Forum List  »  Newbie

Re: Inserting a MySQL select result not working? part 2
Posted by: Peter Brawley
Date: October 25, 2017 09:09PM

If you find yourself flailing, stop. When a query that's been returning result rows stops doing so for no apparent reason, you run each part of the query by itself, then in combination, till you've identified what's gone awry.

Here's your problem ...

> AND x.species_code_c <> NULL

SQL logic is three-valued. There are three possible results from a logical test: true (1), false (0) and Null.

Null is equal to nothing, not even itself. Neither is it unequal. Roughly speaking, it means "unknown". Try this in the mysql client ...

select null<>null, null=null;

Both return null.

So ...AND x.species_code_c <> NULL... must always return Null. You needed:

...AND x.species_code_c IS NOT NULL...

IS and IS NOT return true or false for tests against Null.

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.