WHERE all IS NOT NULL

后端 未结 9 1826
暖寄归人
暖寄归人 2020-12-10 10:38

How can I run a MySQL query that selects everything that is not null? It would be something like

SELECT * FROM schedule WHERE ((all)) IS NOT NULL
         


        
9条回答
  •  感动是毒
    2020-12-10 11:22

    I would not do this, but to replace someone else's horrible idea., especially do not do this -- this is what they suggested:

    SELECT *
      FROM SCHEDULE
     WHERE ID || FOO || BAR IS NOT NULL;
    

    Don't do this either, but at least it isn't as bad...

    SELECT *
      FROM SCHEDULE
    WHERE coalesce(ID, FOO, BAR) IS NOT NULL;
    

    This at least works on other versions of SQL, and some compilers will expand it to a series of IS NOT NULL.

    Just do what the accepted answer says

提交回复
热议问题