How do i get all the NULL valued records from the table without using below conditions
如何在不使用以下条件的情况下从表中获取所有NULL值记录
"WHERE field_name IS NULL OR field_name = 'NULL' "
Is there any MySQL inbuilt function to resolve this..?
是否有任何MySQL内置函数来解决这个问题..?
actually this is what question i have faced in one of the INTERVIEW for MYSQL. i'm very much eager to know the solution for that.
实际上,这是我在其中一个面试中遇到的问题。我非常渴望知道解决方案。
I really appreciate with your answer.Please help me out.
我非常感谢您的回答。请帮帮我。
Thanks.
3 个解决方案
#1
2
you can try this
你可以试试这个
select COALESCE(colname,0) from table where
colname != coalesc(colname,0);
#2
0
you need a Join
and the null-safe equal <=>
你需要一个Join和null-safe equal <=>
SELECT a.*
FROM table a
JOIN (SELECT NULL AS v) b
ON a.field_name <=> b.v
#3
0
you can also try this
你也可以试试这个
SELECT *
FROM test_null
WHERE id NOT IN (
SELECT id
FROM test_null
WHERE !colval
)
#1
2
you can try this
你可以试试这个
select COALESCE(colname,0) from table where
colname != coalesc(colname,0);
#2
0
you need a Join
and the null-safe equal <=>
你需要一个Join和null-safe equal <=>
SELECT a.*
FROM table a
JOIN (SELECT NULL AS v) b
ON a.field_name <=> b.v
#3
0
you can also try this
你也可以试试这个
SELECT *
FROM test_null
WHERE id NOT IN (
SELECT id
FROM test_null
WHERE !colval
)