Comments on: Implicit casting you don’t want to see around https://shlomi-noach.github.io/blog/mysql/implicit-casting-you-dont-want-to-see-around Blog by Shlomi Noach Thu, 08 Jul 2010 22:12:25 +0000 hourly 1 https://wordpress.org/?v=5.3.3 By: Monty Taylor https://shlomi-noach.github.io/blog/mysql/implicit-casting-you-dont-want-to-see-around/comment-page-1#comment-15598 Thu, 08 Jul 2010 22:12:25 +0000 https://shlomi-noach.github.io/blog/?p=2344#comment-15598 ++

I’d also like to point out that passing in your numbers as strings causes the database server to create a Object representing the string value for them and then to convert that into a number which involves a bunch of conversion code. If you just pass it in as a number, then it gets directly shunted into a number in the parser from the protocol.

NEVER a good idea to use “3” if you want it to be a number.

]]>
By: Giuseppe Maxia https://shlomi-noach.github.io/blog/mysql/implicit-casting-you-dont-want-to-see-around/comment-page-1#comment-15537 Wed, 07 Jul 2010 10:25:45 +0000 https://shlomi-noach.github.io/blog/?p=2344#comment-15537 Excellent advice, Shlomi.
For completeness, I should mention that, when using proper date arithmetic syntax, the implicit conversion works as expected.

mysql> SELECT '2010-01-01' + interval 3 day;
+-------------------------------+
| '2010-01-01' + interval 3 day |
+-------------------------------+
| 2010-01-04                    |
+-------------------------------+

mysql> SELECT '2010-01-01' - interval 3 day;
+-------------------------------+
| '2010-01-01' - interval 3 day |
+-------------------------------+
| 2009-12-29                    |
+-------------------------------+
]]>
By: Mrten https://shlomi-noach.github.io/blog/mysql/implicit-casting-you-dont-want-to-see-around/comment-page-1#comment-15536 Wed, 07 Jul 2010 09:51:59 +0000 https://shlomi-noach.github.io/blog/?p=2344#comment-15536 fun if you combine the knowledge from this post with languages that have no strong type (say, php).

]]>