Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the function of functions in mysql and oracle

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces what is the role of functions in mysql and oracle, the content is very detailed, interested friends can refer to, hope to be helpful to you.

1. Nvl () function:

(1) nvl () function in oracle:

Syntax:

Nvl (expr1,expr2)

Meaning:

Returns expr2 if expr1 is empty, and expr1 if the expr1 value is not empty.

(2) "nvl ()" function in mysql:

Syntax:

If null (expr1,expr2)

Meaning:

Returns expr2 if expr1 is empty, and expr1 if the expr1 value is not empty.

Second, decode () function:

(1) decode () function in oracle:

Syntax:

Decode (condition, value 1, return value 1, value 2, return value 2, … Value n, return value n, default value).

Meaning:

When the value of the condition is equal to the value 1, the value 1 is returned, when the value of the condition is equal to the value 2, the value 2 is returned, when the value of the condition is equal to the value n, the value n is returned, and if the condition and the value 1-value n do not want to wait, the default value is returned. Equivalent to if-else in java.

(2) "decode ()" function in mysql:

Syntax:

Ifnull (

Etl (

Filed (col, …)

)

)

Filed function:

Grammar: filed (str,str1,str2,str3... .)

Meaning: return str in str1,str2,str3. .. Returns 1 str=str1 if str=str2, 2 if the position in the. If there is no value for str in str1-strn, 0 is returned.

Note: if str is NULL, the return value is 0 because NULL cannot be compared equally with any value.

Elt function:

Syntax: elt (NMagol str1, recital str2, str3, … Strn)

Meaning: if Number1, str1,N=2 is returned, str2,N > ncentine is returned, and null is returned.

Ifnull function:

Syntax: if null (expr1,expr2)

Meaning: returns expr2 if expr1 is empty, and expr1 if the expr1 value is not empty.

Summarize the above three functions:

Decode (condition, value 1, return value 1, value 2, return value 2, … Value n, return value n, default)

Equivalent to:

Ifnull (elt (filed (condition, value 1, value 2... . Value n), return value 1, return value 2... .. Return value n), default)

3. Pagination:

(1) pagination in oracle:

Syntax:

Select * from (select t.*, rownum r from table name t) where r > 10 and R10 and r

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report