Get the App
SLTechnology News&Howtos  ›  Database  › 

MySQL fundamentals (03): summary of system and custom functions, detailed use of triggers

Shulou Source: shulou.com Published: 2022-06-01 08:41:00 10月05日 Update

Source code of this article: GitHub click here | | GitEE click here |

I. the system encapsulates the function

MySQL has many built-in functions that can quickly solve some business requirements in development, including process control functions, numeric functions, string functions, date-time functions, aggregate functions, and so on. The functions commonly used in these classifications are listed below.

1. Control flow function case...when

The return value is judged according to the value, and the IF-ELSE judgment in analogical programming.

-- DEMO 01SELECT CASE DATE_FORMAT (NOW (),'% Ymuri% mmi% d') WHEN '2019-12-29' THEN 'today' WHEN' 2019-12-28 'THEN' yesterday' WHEN '2019-12-30' THEN 'tommor' ELSE' Unknow' END;-- DEMO 02SELECT (CASE WHEN 1 > 0 THEN 'true' ELSE' false' END) AS result;if (expr1,expr2,expr3)

If the expression expr1 is TRUE, the return value of IF () is expr2;, otherwise the return value is expr3.

SELECT IF (1 > 2)

Tags: Functions triggers statements characters strings data dates users formats types time storage events transactions parameters addresses backups numeric values numbers environment Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia MariaDB Redmi macOS Shulou Information