---
title: "mysq 存储过程判断为空null , mysql存储过程 字符串拼接"
author: "不念书的小子"
date: "2012-06-26T16:21:11Z"
tags: []
categories: ["数据库"]
slug: "mysq-null-mysql"
draft: false
lastmod: "2012-06-26T16:21:11Z"
id: 1568213
url: "https://tompig.iteye.com/blog/1568213"
---

mysq 存储过程判断为空null , mysql存储过程 字符串拼接,mysq 存储过程判断为空null , mysql存储过程 字符串拼接,mysq 存储过程判断为空null , mysql存储过程 字符串拼接.

 

mysq 存储过程判断为空null 方法：

 

if i\_os\_type='' then  
      set os\_type\_sql=CONCAT('=','');  
   elseif i\_os\_type is null then  
      set os\_type\_sql=' is null';  
   else  
      set os\_type\_sql=CONCAT('=',i\_os\_type);  
   end if;

 

mysql存储过程 字符串拼接方法：

 

DECLARE  os\_type\_sql VARCHAR(100);

 if i\_os\_type='' then  
      set os\_type\_sql=CONCAT('=','');  
   elseif i\_os\_type is null then  
      set os\_type\_sql=' is null';  
   else  
      set os\_type\_sql=CONCAT('=',i\_os\_type);  
   end if;