如题
比如在一个表里,我要返回每个字段内容,但其中某个字段我不需要它的内容,只要返回有内容就true,没内容就false.可以直接在sql语句里面进行判断吗?我不想在程序里判断,因为我觉得那样会占更多的服务器资源...所以就只想在sql里判断好.

解决方案 »

  1.   

    select col is null from table1;
      

  2.   

    或者select isnull(col) from table1;
      

  3.   

    select isnull(col) from table1;
    or
    select COALESCE(col,1) from table1;
      

  4.   

    select case when length(a)>0 then 'true' else 'false' end from table1
      

  5.   

    没有内容是指null就是上面说的is null,如果空串(0长度字符串)也算空
    select length(ifnull(col, '')) > 0