当前位置:网站首页>Database SQL language 06 single line function
Database SQL language 06 single line function
2022-06-30 05:22:00 【Chao Ge 1986】
String functions and mathematical functions
SELECT ABS(-8); /* The absolute value */
SELECT CEILING(9.4); /* Rounding up */
SELECT FLOOR(9.4); /* Rounding down */
SELECT RAND(); /* random number , Return to one 0-1 Random number between */
SELECT SIGN(0); /* Symbolic function : A negative number returns -1, A positive number returns 1,0 return 0*/
SELECT CHAR_LENGTH(' Crazy God says persistence can succeed '); /* Returns the number of characters contained in a string */
SELECT CONCAT(' I ',' Love ',' Program '); /* Merge strings , Parameters can have multiple */
SELECT INSERT(' I love programming. helloworld',1,2,' Super love '); /* Replace string , Start from a certain position to replace Change a certain length */
SELECT LOWER('KuangShen'); /* A lowercase letter */
SELECT UPPER('KuangShen'); /* Capitalization */
SELECT LEFT('hello,world',5); /* Cut from the left */
SELECT RIGHT('hello,world',5); /* Cut from the right */
SELECT REPLACE(' Crazy God says persistence can succeed ',' insist ',' Strive '); /* Replace string */
SELECT SUBSTR(' Crazy God says persistence can succeed ',4,6); /* Intercepting string , Start and length */
SELECT REVERSE(' Crazy God says persistence can succeed '); /* reverse
-- Look up the students surnamed Zhou , Change to Zou
SELECT REPLACE(studentname,' Zhou ',' Zou ') AS New name
FROM student WHERE studentname LIKE ' Zhou %';
Date and time functions
SELECT CURRENT_DATE(); /* Get current date */
SELECT CURDATE(); /* Get current date */
SELECT NOW(); /* Get the current date and time */
SELECT LOCALTIME(); /* Get the current date and time */
SELECT SYSDATE(); /* Get the current date and time */
-- Get date , Minutes and seconds
SELECT YEAR(NOW());
SELECT MONTH(NOW());
SELECT DAY(NOW());
SELECT HOUR(NOW());
SELECT MINUTE(NOW());
SELECT SECOND(NOW());
– Numerical function
abs(x) -- The absolute value abs(-10.9) = 10
format(x, d) -- Format the number of thousandths format(1234567.456, 2) = 1,234,567.46
ceil(x) -- Rounding up ceil(10.1) = 11
floor(x) -- Rounding down floor (10.1) = 10
round(x) -- Round to the nearest whole
mod(m, n) -- m%n m mod n Seeking remainder 10%3=1
pi() -- Get the pi
pow(m, n) -- m^n
sqrt(x) -- Arithmetical square root
rand() -- random number
truncate(x, d) -- Intercept d Decimal place
– Time date function
now(), current_timestamp(); -- Current date time
current_date(); -- The current date
current_time(); -- current time
date('yyyy-mm-dd hh:ii:ss'); -- Get the date part
time('yyyy-mm-dd hh:ii:ss'); -- Get the time part
date_format('yyyy-mm-dd hh:ii:ss', '%d %y %a %d %m %b %j'); -- Format time
unix_timestamp(); -- get unix Time stamp
from_unixtime(); -- Get the time from the time stamp
– String function
length(string) -- string length , byte
char_length(string) -- string Characters of
substring(str, position [,length]) -- from str Of position Start , take length Characters
replace(str ,search_str ,replace_str) -- stay str of use replace_str Replace search_str
instr(string ,substring) -- return substring First time in string Where in
concat(string [,...]) -- Connection string
charset(str) -- Returns the string character set
lcase(string) -- Convert to lowercase
left(string, length) -- from string2 From the left side of length Characters
load_file(file_name) -- Read from file
locate(substring, string [,start_position]) -- Same as instr, But you can specify the starting position
lpad(string, length, pad) -- Repeat pad Add to string start , Until the string length is length
ltrim(string) -- Remove the front space
repeat(string, count) -- repeat count Time
rpad(string, length, pad) -- stay str After use pad Add , Until the length is length
rtrim(string) -- Remove back-end space
strcmp(string1 ,string2) -- Compare the size of two strings character by character
-- Aggregate functions
count()
sum();
max();
min();
avg();
group_concat()
边栏推荐
- Unity C trigonometric function, right triangle corner calculation
- Word frequency statistics (string, list)
- Read and save txt files
- Unity packaging and publishing webgl error reason exception: failed building webgl player
- 东塔攻防世界—xss绕过安全狗
- Unity Catmull ROM curve
- Redistemplate common method summary
- Leetcode 180 Consecutive numbers (2022.06.29)
- Installation and getting started with pytoch
- 旋转框目标检测mmrotate v0.3.1 训练DOTA数据集(二)
猜你喜欢
[learning notes] AssetBundle, xlua, hot update (use steps)
Unity publishing /build settings
Writing unityshader with sublimetext
How to judge the quality of network transformer? What symptom is network filter transformer broken?
Terminal convenient SSH connection
Unit asynchronous jump progress
East Tower attack and defense world - XSS bypasses the safety dog
【LeetCode】Easy | 232. Using stack to realize queue (pure C manual tearing stack)
Super comprehensive summary | related improvement codes of orb-slam2 / orb-slam3!
Unity C trigonometric function, right triangle corner calculation
随机推荐
Rotation, translation and scaling of unity VR objects
Initial environment configuration of the list of OpenGL super classic (version 7) vs2019
After reading who moved my cheese
Chapter 8 primitive processing of OpenGL super classic (version 7)
[note] usage model tree of the unity resource tree structure virtualizingtreeview
Word frequency statistics (string, list)
[notes] unity webgl input Chinese
【LeetCode】Easy | 232. Using stack to realize queue (pure C manual tearing stack)
Unity determines whether the UI is clicked
14x1.5cm vertical label is a little difficult, VFP calls bartender to print
Redistemplate common method summary
C # three ways to obtain web page content
Nestjs配置静态资源,模板引擎以及Post示例
VFPBS在IIS下调用EXCEL遇到的Access is denied
Responsive layout
Unity Catmull ROM curve
[typescript] defines the return value type of promise
Unity limited time use limited trial time and use times
Untiy3d controls scene screenshots through external JSON files
Unity3d learning notes-1 (C # learning)