当前位置:网站首页>Oracle code use

Oracle code use

2022-07-05 07:13:00 Just as young

Preface

When maintaining company code , It was found that ORACLE SQL To write the mapper.xml Of documents , There's a decode function , Let's learn its usage .

Use

Here is a simple usage

decode( Name or Operation expression , Judge the condition , value 1, value 2)

If 【 Name or Operation expression 】 The value of is equal to the judgment condition , Then return the value 1, Otherwise, return the value 2. Let's take a concrete example , Suppose the table name is table:

decode(table.id,null,0,1)

The above example means table.id If null, Whole decode The value of the expression is 0, Otherwise 1. Of course , In most cases, we will use and for comparison :

select *
from table
where decode(table.id,null,0,1)=1

That's all decode Simple usage .

原网站

版权声明
本文为[Just as young]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140559379864.html