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

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -