Common math functions for MySQL

Source: Internet
Author: User
Tags square root

Use MySQL's own function to be cautious, say that it will affect the efficiency of data execution, the cost is too high. This also to distinguish between the reference category of fast software, such as the internal system business logic is more complex, the function point is very fine, but the concurrency is not very large, this time with the MySQL function can greatly reduce the business logic of the development of the difficulty (although said to be one-sided, can not be generalize, but there is a great use) While the external system business logic is relatively not very complex, the function point is relatively shallow, but the concurrency ratio is large, in order to reduce the server and database access pressure is best not to use the own function, the reason is simple is the performance problem.

1, theformat (x, y) function, the function is to place a number x, the y decimal place is reserved, and the integer part is separated by commas, the fractional part is rounded.

  

- Note : Once your data is separated by thousands of bits, it becomes a string . can provide a better experience for reading, but it is very difficult to calculate, so if you just keep the decimal, it is not recommended to use this function.

2,abs (); To find the absolute value of a number; absolute

3,sqrt (); Ask for the square root of a number. SQRT is the abbreviation for Sqruar (square, rectangle), root (Root).

4,mod (x, y) × divisor, y dividend. The end is the remainder.

  

5,ceil () into a rounding.

Floor () Rounding and rounding

These two functions are mirror functions, which are somewhat more interesting. These two functions are not rounded and are more robust.

  

6,rand () as the name implies, is used to generate random numbers.

  

7,format will automatically do thousands of bits, the following we look at the round function, to be rounded.

  

8,truncate (x, y) compare overbearing, regardless of rounding, directly to X, the y decimal place directly killed.

  

9, sign() returns the current result of the symbol, if a negative number returns-1, if 0 returns 0 if it is positive, returns 1.

  

10. Power() power operation

  

Original: Http://www.cnblogs.com/roverliang/p/5060756.html?utm_source=tuicool&utm_medium=referral

Common math functions for MySQL

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.