Re: Inserting a MySQL select result not working? part 2
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.