Wow. I've seen some odd behavior in SQL before, but this one seems to defy logic. Maybe I'm missing something obvious.
It hinges on a fairly simple logic statement: Given that a record exists in one table, then a matching record either exists in another table or it does not exist in that table. It's logically impossible for it to both exist and not exist in a macroscopic universe.
But when I run these three queries:

I get the following result:
1st query: 1 result.
2nd query: zero results.
3rd query: zero results.
If the first query came up empty, it would make sense that the second two would also return zero results. If it exists, though, how can it both NOT exist and NOT NOT exist?
If there were no records at all in the second table, then the second query should return one row. If there were a zillion records but none matched, it would return one row. If the table or column didn't exist, it would throw an error. That leaves one other possibility: That there is a matching record in the second table, which means the third query would return one row.
But it doesn't.
I've distilled the queries down as simply as I could to remove the possibility of any fat-fingering, but I just can't wrap my head around this one.
It hinges on a fairly simple logic statement: Given that a record exists in one table, then a matching record either exists in another table or it does not exist in that table. It's logically impossible for it to both exist and not exist in a macroscopic universe.
But when I run these three queries:
I get the following result:
1st query: 1 result.
2nd query: zero results.
3rd query: zero results.
If the first query came up empty, it would make sense that the second two would also return zero results. If it exists, though, how can it both NOT exist and NOT NOT exist?
If there were no records at all in the second table, then the second query should return one row. If there were a zillion records but none matched, it would return one row. If the table or column didn't exist, it would throw an error. That leaves one other possibility: That there is a matching record in the second table, which means the third query would return one row.
But it doesn't.
I've distilled the queries down as simply as I could to remove the possibility of any fat-fingering, but I just can't wrap my head around this one.
via JREF Forum http://ift.tt/1ggu0jA
Aucun commentaire:
Enregistrer un commentaire