由于各种原因,数据的原则问题,导致某个字段上出现多个数据(依据分隔符隔开),比如 name 字段为 张三;李四;王五等等 需求:求一张表中name字段中出现的个数: 想要得到的结果为: 对应的sql语句: ------------------------创建表,添加数据----------------------- create table t_student( id number(2) primary key, name varchar(10) not null, age varchar(2)
比如 insert into table a (a1,b1)values("a1",''); 对于这种情况,因为表里存的是'',其实是没有内容的,要查询这个字段,不能直接使用 select * from a where b1=''; sql中判断非空不能用等号,因为null在sql中被看作特殊符号,必须使用关键字 is和not应该如此使用: select * from A where b1 is null 或者: select * from A where b1 is not null
select * from a where instr(a,b)>0; 用于实现B字段是A字段中的某一部分的时候,要论顺序或者要相邻的字符. 如果想要不论顺序或者不相邻的字符时,定义函数可以实现: select * from a where instr(a,b)>0; 这个只能实现B字段是A字段中的某一部分的时候. 如果想要不论顺序或者不相邻的字符时,定义函数可以实现 create or replace function checks(v_a varchar2,v_b varchar) ret
oracle数据库根据不同条件给同一字段修改相应的值: 例如:根据职务调整雇员的工资,如果职务为“SALESMAN”或者“ANALYST”工资上调100元,如果职务为“MANAGER”工资上调200元,其它职务工资上调50元. update emp set sal=( case when job in('SALESMAN','ANALYST') then sal+100 when job = 'MANAGER' then sal+200 else sal+50 end ); 查询出当前的orac
判断一个int值是几位数,要是我自己实现,估计又会想到除法和模运算了,偶然在java标准API源码中发现的写法,很强大. public class Test { final static int[] sizeTable = { 9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999, Integer.MAX_VALUE }; static int sizeOfInt(int x) { for (int i = 0;; i++)
在JavaScript的数字类型Number中,我们最常使用的大概是整数类型与浮点数类型,但除这两者外,还有个特殊的存在NaN,为什么NaN!==NaN?我们如何判断一个值是否等于NaN呢?这篇文章好好聊聊NaN. 1.NaN是什么? NaN全称是Not-A-Number(不是一个数字),我们可以通过Number.NaN来获得一个NaN,在类型转换失败时,我们常常会得到一个NaN,需要注意的是,NaN是JS中唯一一个自身不相等的存在. Number.NaN //NaN NaN === NaN /
Array.prototype.indexOf = function (val) {//判断数组是否存在某个值,如果存在返回该值对应的索引,否则返回-1 for (var i = 0; i < this.length; i++) { if(typeof val === 'object' && typeof this[i]==='object'){ var str1 = JSON.stringify(val); var str2 = JSON.stringify(this[i]); i
update (select length(t.name), t.* -- name,length(name) from g_enterprise_info t where nvl2(translate(name, '\1234567890 ', '\'), 'is characters ', 'is number ') = 'is number ' and asciistr(gszcdjh) like '%\%') set name = gszcdjh, gszcdjh =name ; 判断一