六月婷婷综合激情-六月婷婷综合-六月婷婷在线观看-六月婷婷在线-亚洲黄色在线网站-亚洲黄色在线观看网站

明輝手游網(wǎng)中心:是一個免費提供流行視頻軟件教程、在線學(xué)習(xí)分享的學(xué)習(xí)平臺!

mysql求2個或以上字段為NULL值的案例分享

[摘要]本文主要介紹了mysql 求解求2個或以上字段為NULL的記錄,需要的朋友可以參考下,希望能幫助到大家。核心代碼/*--------------------------------求2個或以上字段為...
本文主要介紹了mysql 求解求2個或以上字段為NULL的記錄,需要的朋友可以參考下,希望能幫助到大家。

核心代碼


/*--------------------------------
求2個或以上字段為NULL 的記錄
t1:
id, id1, id2, id3, id4, id5, id6
在t1 表中有個字段;
其中id是主鍵;
怎樣打印其中個字段或以上為NULL 的記錄id?
另外,存儲過程中怎么實現(xiàn)按順序一條一條讀取記錄最方便?
注:主鍵id 是沒有順序的,也可能是字符串的;
-----------------------------------------*/
drop table if exists t1;
create table t1(id int,id1 int,id2 int,id3 int,id4 int,id5 int,id6 int);
insert t1 select
1,1,1,1,1,null,null union all select 
2,null,null,null,1,2,3 union all select 
3,1,2,3,4,5,6 union all select 
4,1,2,3,4,5,null union all select 
5,null,3,4,null,null,null ;
delimiter $$
create procedure usp_c_null()
begin 
declare n_c int;
declare idd int;
declare cur cursor for 
select id,case char_length(concat(ifnull(id1,'@'),ifnull(id2,'@'),ifnull(id3,'@'),ifnull(id4,'@'),ifnull(id5,'@'),ifnull(id6,'@')))
-char_length(replace(concat(ifnull(id1,'@'),ifnull(id2,'@'),ifnull(id3,'@'),ifnull(id4,'@'),ifnull(id5,'@'),ifnull(id6,'@')),'@','') )
 when 6 then 6 when 5 then 5 when 4 then 4  when 3 then 3 when 2 then 2 when 1 then 1 else 0 end as c from t1;
declare exit HANDLER for not found close cur ;
open cur;
repeat 
fetch cur into idd,n_c;
if(n_c>=2) then
select * from t1 where id=idd;
end if ;
until 0 end repeat;
close cur;
end ;
$$
delimiter ;
/*
+------+------+------+------+------+------+------+
  id    id1   id2   id3   id4   id5   id6  
+------+------+------+------+------+------+------+
   1    1    1    1    1   NULL   NULL  
+------+------+------+------+------+------+------+
1 row in set (0.10 sec)
+------+------+------+------+------+------+------+
  id    id1   id2   id3   id4   id5   id6  
+------+------+------+------+------+------+------+
   2   NULL   NULL   NULL    1    2    3  
+------+------+------+------+------+------+------+
1 row in set (0.14 sec)
+------+------+------+------+------+------+------+
  id    id1   id2   id3   id4   id5   id6  
+------+------+------+------+------+------+------+
   5   NULL    3    4   NULL   NULL   NULL  
+------+------+------+------+------+------+------+
1 row in set (0.17 sec)
*/

相關(guān)推薦:

MySQL中的唯一性約束與NULL實例詳解

JavaScript中undefined與null的區(qū)別詳解

如何用js判斷null值

以上就是mysql求2個或以上字段為NULL值的實例分享的詳細內(nèi)容,更多請關(guān)注php中文網(wǎng)其它相關(guān)文章!


學(xué)習(xí)教程快速掌握從入門到精通的SQL知識。




主站蜘蛛池模板: 日本高清视频在线的 | 日本欧美一区二区三区 | 亚洲va中文字幕 | 日韩高清免费观看 | 一级黄色免费片 | 亚洲色域网 | 色偷偷成人 | 亚洲天堂视频一区 | 亚洲a成人7777777久久 | 亚洲福利一区 | 四虎国产精品免费观看 | 亚洲国产成人久久一区www | 手机看片日韩日韩韩 | 日本高清视频色 | 日本一本在线视频 | 色综合天天综合网站中国 | 色在线播放 | 亚洲欧美另类国产 | 四虎影院在线 | 亚洲欧洲精品视频 | 中国日韩欧美中文日韩欧美色 | 人人擦人人| 青草草视频在线观看 | 日本午夜免费福利视频 | 欧美亚洲免费久久久 | 亚洲成a人片在线看 | 五月激情啪啪 | 一区二区三区在线 | 网站 | 天天操天天艹 | 日韩在线不卡视频 | 性久久久久久久久 | 亚洲日本欧美在线 | 亚洲天堂精品在线观看 | 日韩精品手机在线 | 一二三四影院网在线观看免费 | 色妞bbbb女女女女 | 片成年免费观看网站黄 | 中文字幕自拍 | 欧美婷婷六月丁香综合色 | 亚洲欧洲一区二区三区在线观看 | 天天看毛片|