The most frequently used function of the sql statement (the simplest)

function

Functions can be roughly divided into the following types:

  • Arithmetic functions (functions used to perform numerical calculations)
  • String functions (functions used to perform string operations)
  • Date function (function used for date manipulation)
  • Conversion functions (functions used to convert data types and values)
  • Aggregation functions (functions used for data aggregation)

String function

  • || ——Splice
    String 1 || String 2
    || The function cannot be used in SQL Server and MySQL.

  • LENGTH- string length LENGTH (string)
  • LOWER-Lowercase conversion
    LOWER (string)
  • REPLACE-- replacement string
    will replace a portion of the string to other strings
    REPLACE (target character string, character string before the replacement, the replacement string)
  • SUBSTRING-string interception
    SUBSTRING (the starting position of the object string FROM interception FOR the number of characters intercepted)
  • UPPER-uppercase conversion
    UPPER (string)

Date function

  • CURRENT_DATE-Current date The
    CURRENT_DATE function can return the date of SQL execution, that is, the date when the function was executed. Because there are no parameters, no parentheses are required
  • CURRENT_TIME-the current time
    CURRENT_TIME function can get the time of SQL execution, which is the time when the function is executed
  • CURRENT_TIMESTAMP-current date and time
  • CAST-type conversion
    CAST (value before conversion AS the type of data you want to convert)
  • COALESCE——Convert NULL to other values
    COALESCE (Data 1, Data 2, Data 3 ...)
    COALESCE is a SQL-specific function.

LIKE predicate-part of the string consistent query

Partial agreement can be roughly divided into three types: front agreement, middle agreement and rear agreement.

  • "%" Is a special symbol for "any string above 0 characters"
  • "_" Stands for "any 1 character".

IS NULL, IS NOT NULL-judge whether it is NULL

IN predicate-simple usage of OR

IN (value 1, value 2, value 3, ...) replace multiple OR
NOT IN (value 1, value 2, value 3, ...)
Note:

  • NULL data cannot be selected for IN and NOT IN.
  • Subqueries can be used as parameters for IN predicates

 


 

Published 13 original articles · Likes0 · Visits 1941

Guess you like

Origin blog.csdn.net/Beautifulcoco/article/details/103694064