database - mysql single quote in arithmatic functions -
in mysql, if like
round((amount * '0.75'),2) it seem work fine without single quotes 0.75. there difference in how mysql process this?
in hope close out question, here's link explains type conversion in expression evaluation: https://dev.mysql.com/doc/refman/5.5/en/type-conversion.html
when operator used operands of different types, type conversion occurs make operands compatible. conversions occur implicitly. example, mysql automatically converts numbers strings necessary, , vice versa.
mysql> select 1+'1'; -> 2 in case, mysql sees arithmetic , performs implicit conversion on string contained in expression. there going overheard in converting string number, it's negligible. preference explicitly type out number instead of quoting it. method has helped me in code clarity , maintainability.
Comments
Post a Comment