mysql calculation function details

mysql calculation function details

Functions are not as portable as SQL . Code that can run on multiple systems is called portable . Most SQL statements are relatively portable, and when there are differences between SQL implementations, those differences are usually not that difficult to deal with.

However, the portability of functions is not strong. Almost every major DBMS implementation supports functions that other implementations do not, and the differences are sometimes significant. For the sake of code portability, many SQL programmers do not favor the use of special implementation features. Although this is beneficial,

But it is not always good for application performance. Without using these functions, writing some application code would be difficult. Other methods must be utilized to accomplish the work that the DBMS does very efficiently.

If you decide to use functions, you should make sure to comment your code so that later on you (or others) know exactly what the SQL you wrote means.

2. Field concatenation

SELECT CONCAT(vend_name,'(',vend_country,')') as info
from vendors
ORDER BY vend_name

MySQL also supports the following operators:

2. Give some examples of mysql functions

2.1 Symbol Processing

Left() Returns the characters on the left side of a string Length() Returns the length of a string Locate() Finds a substring of a string Lower() Converts a string to lowercase LTrim() Removes spaces on the left side of a string Right() Returns the characters on the right side of a string RTrim() Removes spaces on the right side of a string Soundex() Returns the SOUNDEX value of a string SubString() Returns the characters of a substring Upper() Converts a string to uppercase

2.2 Phase Treatment

AddDate() adds a date (day, week, etc.)
AddTime() adds a time (hour, minute, etc.)
CurDate() Returns the current dateCurTime() Returns the current timeDate() Returns the date portion of a date and timeDateDiff() Calculates the difference between two datesDate_Add() Highly flexible date operation functionDate_Format() Returns a formatted date or time stringDay() Returns the day portion of a dateDayOfWeek() Returns the corresponding day of the week for a dateHour() Returns the hour portion of a timeMinute() Returns the minute portion of a timeMonth() Returns the month portion of a dateNow() Returns the current date and timeSecond() Returns the seconds portion of a timeTime() Returns the hour portion of a date and timeYear() Returns the year portion of a date

2.3 Value Processing

Abs() Returns the absolute value of a numberCos() Returns the cosine of an angleExp() Returns the exponential value of a numberMod() Returns the remainder of a division operationPi() Returns the ratio of piRand() Returns a random numberSin() Returns the sine of an angleSqrt() Returns the square root of a numberTan() Returns the tangent of an angle

This is the end of this article about the details of mysql calculation functions. For more relevant mysql calculation function content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • MySQL detailed summary of commonly used functions
  • Comprehensive summary of mysql functions
  • A brief introduction to MySQL functions
  • Introduction to commonly used functions in MYSQL database

<<:  Click the button to turn the text into an input box, click Save to turn it into text implementation code

>>:  Negative margin function introduction and usage summary

Recommend

Detailed explanation of various loop speed tests in JS that you don’t know

Table of contents Preface 1. for loop 2. while lo...

MySQL restores data through binlog

Table of contents mysql log files binlog Binlog l...

Understand the principle of page replacement algorithm through code examples

Page replacement algorithm: The essence is to mak...

Tutorial on logging into MySQL after installing Mysql 5.7.17

The installation of mysql-5.7.17 is introduced be...

Implementation of proxy_pass in nginx reverse proxy

The format is simple: proxy_pass URL; The URL inc...

Vue.js implements the nine-grid image display module

I used Vue.js to make a nine-grid image display m...

Detailed explanation of the Sidecar mode in Docker Compose

Table of contents What is Docker Compose Requirem...

A brief discussion on the role of the docker --privileged=true parameter

Around version 0.6, privileged was introduced to ...

VScode Remote SSH remote editing and debugging code

The latest Insider version of Visual Studio Code ...

How to analyze MySQL query performance

Table of contents Slow query basics: optimizing d...

Analysis of the principle of Vue nextTick

Table of contents Event Loop miscroTask (microtas...

MySQL 5.7.18 version free installation configuration tutorial

MySQL is divided into installation version and fr...

Analysis of the pros and cons of fixed, fluid, and flexible web page layouts

There is a question that has troubled web designe...

WeChat applet implements countdown for sending SMS verification code

This article shares the specific code for the WeC...