Hot to display the NOT NULL values in table without using keyword NOT NULL?
Asked
Active
Viewed 460 times
-2
-
2Your question doesn't make sense. Provide sample data, desired results, and tag with the database you are using. Also, explain the issues with `NOT NULL`. – Gordon Linoff May 03 '17 at 12:15
-
is this some homework question? – Pepo_rasta May 03 '17 at 12:17
-
Consider the table with NULL values. Now select the NOT NULL values without using NOT NULL keyword. – D. kishor kumar May 03 '17 at 12:17
-
Possible duplicate of [MySQL SELECT only not null values](http://stackoverflow.com/questions/5285448/mysql-select-only-not-null-values) – Steve Lovell May 03 '17 at 12:18
-
Yes.....Its home work question. I searched for and didnt able to find the answer – D. kishor kumar May 03 '17 at 12:18
-
Can you use `IS NULL`? – nonzaprej May 03 '17 at 12:21
-
Well, you can use the null verification function, and since you didn't provide which RDBMS, we have to guess, right? If you're using Sql Server, you can use the isnull function, or the NVL function, if you're using Oracle. – Renato Afonso May 03 '17 at 12:21
-
Your professor probably wants you to make an INNER JOIN between 2 tables, which would eliminates NULLs. Show the whole stuff! – Thomas G May 03 '17 at 12:21
-
Yes we can use IS NULL – D. kishor kumar May 03 '17 at 12:22
-
You can improve the quality of your Question by showing us the structure of your tables along with some sample data. Also, please show us what code you have tried (if any) and the full text of any error messages it produces. Please read http://stackoverflow.com/help/how-to-ask for more information on how to ask a good Question. – toonice May 03 '17 at 12:22
-
Thomas G. You are right I think. Thank you for you r suggestion – D. kishor kumar May 03 '17 at 12:23
2 Answers
2
There are a few ways to do this, the first I think of is doing some sort of arithmetic in the where clause then orienting it so that it will always pass. The NULL value records will fail the where clause and drop off the result set.
Select *
From Table
Where ID * 1 = ID
If you don't have a number to use, you can instead:
Select *
From Table
Where StringID + '' = StringID

Mukesh Kalgude
- 4,814
- 2
- 17
- 32

Combee Bowlin
- 106
- 5
1
SELECT * FROM Table1 WHERE Id NOT IN (
SELECT Id FROM Table1 WHERE Column1 IS NULL
);
Assuming the unique identifier column (if there's one) is called "Id".

nonzaprej
- 1,322
- 2
- 21
- 30