如何在一个表中查询不为空的列,select * from 表名 where 列名 is not null 这个怎么查不出来,谢谢各位大侠

解决方案 »

  1.   

    select * from 表名 where 列名 is not null
    查出的是该列不为空的N行数据
    至于你说的想用 select * 查出不为空的'列',我想是无法实现的
      

  2.   

    select distinct sect_office from users where sect_office is not null 
    表结构如下:
    userid  name  sect_office depart
    1       aa                w1
    2       bb    ddb         w1
    3       cc    ddb         w1
    4       dd                w1
    就这样得表结构,要查询sect_office不为空得记录,是depart和sect_office得ajax联动,用select distinct sect_office from users where sect_office is not null and dept='w1'查是错误得
      

  3.   


    是这样的吧:
    select distinct sect_office from users where sect_office='w1' and sect_office is not null; 
      

  4.   


    你可以查询出来列的值,但是你查询不出来为null的那个列名字啊!你可以上视图里面desc下表结构,看下那列可以为null。
      

  5.   

    userid  name   sect_office   depart 
    1        aa                    w1 
    2        bb      ddb           w1 
    3        cc      ddb           w1 
    4        dd                    w1 
    就这样得表结构,要查询sect_office不为空得记录,是depart和sect_office得ajax联动,用select distinct sect_office from users where sect_office is not null and depart ='w1'查是错误得,可能是这样的表结构,我以前遇到过,没解决,求解各位大侠了
      

  6.   

    是depart和sect_office得ajax联动???
    不是很明白
      

  7.   

    是depart和sect_office得ajax联动??? 
      

  8.   

    select *from pj_ckls(表名) where ckpaper(列名) not in (select ckpaper(列名) from pj_ckls(表名))