Re: Data Types in MySQL

From: Lennart Jonsson <erik.lennart.jonsson_at_gmail.com>
Date: Mon, 17 Nov 2014 16:14:33 +0100
Message-ID: <m4d3cd$5jq$1_at_dont-email.me>


On 2014-11-17 10:53, Stefan Ram wrote:
> In programming languages, a function parameter often has a
> data type. The argument then must have the same type.
>
> In the MySQL documentation, I can read:
>
> ACOS(X)
>
> Returns the arc cosine of X, that is, the value whose
> cosine is X. Returns NULL if X is not in the range -1 to 1.
>
> But nowhere does it says something about the type of X.
>
> SELECT ACOS( '0' );
>
> +--------------------+
> | ACOS( '0' ) |
> +--------------------+
> | 1.5707963267948966 |
> +--------------------+
>
> »'0'« is a string. ACOS accepts it without a warning.
>
> Where can one read in the documentation about the rules
> leading to this behavior? Where does the documentation
> say that such a string literal is allowed when a number X
> is expected?
>

You can have a look at:

http://dev.mysql.com/doc/refman/5.5/en/type-conversion.html

Not sure that it answers your question completely, but you can use as a starting point.

Basically MySQL tries to be friendly by implicitly casting between types, sometimes the result makes sense, sometimes it does not.

/Lennart

[...] Received on Mon Nov 17 2014 - 16:14:33 CET

Original text of this message