从数据库中取出值后判断是否为空,这个看起来很简单,只要和null比较一下就可以了,其实不然, if($obj==null){ } 这样写会报错的:Notice: Trying to get property of non-object problem, 查了一下发现需要使用下面的写法 if (isset($obj)) { echo "This var is set set so I will print."; } 这个isset是做什么的呢? isset函数是检测变量是否设置. 格式:
mysql中判断字段为null或者不为null 在mysql中,查询某字段为空时,切记不可用 = null, 而是 is null,不为空则是 is not null select nulcolumn from table; if nuncolumn is null then select 1; else select 2; end if; 执行存储过程 调用过程:call sp_add (1,2,@a);select @a;
有时候我们在js中会直接判断变量是否存在值,下面列举一些情况: var a = 0; var b = 1; var c = ' '; var d; console.log( a ? 1 : null); //null console.log( b ? 1 : console.log( c ? 1 : null); //null console.log( d ? 1 : null); //null 上述情况中我们c,d没有值,所以结果是null,但是a的值是0,结果也是null,这里就涉及到一个特