I just discovered you can write something like
SELECT NULL IS UNKNOWN
Which returns 1
.
Are there any other places you can use UNKNOWN
? It doesn't appear to be a keyword (can't do SELECT UNKNOWN
). NULL IS NULL
is also true, so what purpose does UNKNOWN
have?
When connecting to MySQL, I get an "Unknown Database" error. You connect to the wrong cluster. You connect to a database that doesn’t exist in your specified cluster. Verify that you are using the correct hostname to connect.
Finally, the error can also be caused by invisible characters lurking in your script that can’t be seen when you copy and paste it from other sources. The only way to remove invisible characters is by rewriting the statements manually. The tutorial above has listed the most common cause for MySQL unknown column in field list error.
This may be checked by looking in /var/lib/mysql for a mysql subfolder (i.e. /var/lib/mysql/mysql ). If the path does NOT contain a mysql subfolder, it needs to be created by completing the following steps: Now that the above steps have been run, check and make sure that the database was created:
Depending on how MySQL was installed, it is possible that the default MySQL database was NOT created. This may be checked by looking in /var/lib/mysql for a mysql subfolder (i.e. /var/lib/mysql/mysql ).
UNKNOWN
is just an alias for BOOLEAN
NULL
... the same way that TRUE
is just an alias for 1
and FALSE
is just an alias for 0
, since in MySql BOOLEAN
itself is just an alias for TINYINT(1)
Why is it even there? Because it's part of the SQL-92 standard:
<truth value> ::=
TRUE
| FALSE
| UNKNOWN
Why can you SELECT NULL
, SELECT TRUE
, SELECT FALSE
, but not SELECT UNKNOWN
? Probably just a bug, since UNKNOWN
itself wasn't supported until newer versions of MySql.
Seems to me, in MySQL, UNKNOWN
is an alias for NULL
, used in a Boolean sense.
I could find this reference:
In SQL, all logical operators evaluate to TRUE, FALSE, or NULL (UNKNOWN).
MySQL docs - 12.3.3. Logical Operators
Some more information on general SQL NULL and UNKNOWN:
When restricted by a NOT NULL constraint, the SQL BOOLEAN works like the Boolean type from other languages. Unrestricted however, the BOOLEAN datatype, despite its name, can hold the truth values TRUE, FALSE, and UNKNOWN, all of which are defined as boolean literals according to the standard. The standard also asserts that NULL and UNKNOWN "may be used interchangeably to mean exactly the same thing".
NULL on Wikipedia
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