开发者

Ms access query for dont show blank filed

开发者 https://www.devze.com 2023-04-11 16:58 出处:网络
I have a query that has a couple of text fields where in the filter criteria I put <> \"Power\". When I put this criteria in, it also does not show me records where the field is blank. If I leav

I have a query that has a couple of text fields where in the filter criteria I put <> "Power". When I put this criteria in, it also does not show me records where the field is blank. If I leave the criteria empty, it shows me all records including the records with the开发者_如何学Python blank fields.

How do I get the query to exclude the criteria Power but still show records where that field is blank?


Try adding an OR IS NULL:

<> "Power" OR IS NULL


SELECT *
  FROM YourTable
 WHERE 'T' = SWITCH(
                    your_col IS NULL,     'T', 
                    your_col = ' ',       'T', 
                    your_col <> 'Power',  'T'
                   );


Try using ANSI SQL function COALESCE like this

SELECT *
FROM MyTable
WHERE COALESCE(MyColumn, '') <> 'Power'


A blank field could mean the field is Null or it contains a zero length string (""). You can test for either of those conditions by concatenating the field with another zero length string. If the string length of that combination is zero, you know the field must be either Null or zero length string.

SELECT *
FROM YourTable
WHERE
       Your_column <> 'Power'
    OR Len(Your_column & '') = 0;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号