sql – How to check all fields of a table for emptyness using is not null?

Question:

using is not null for one field in the request everything works, I add 2 field and it gives an error. Tell me how can I check, for example, 30 fields in the database for emptiness?

SELECT * FROM `datafrom` where `micur`, `mtimein` is not NULL  OR myid='".$umid."'"

Answer:

The COALESCE function will return the value of the first parameter, which is not null .

CREATE TABLE t1 (f1 char, f2 char, f3 char)
/
INSERT INTO t1 VALUES ('x', null, null);
INSERT INTO t1 VALUES (null, null, null);

SELECT *
FROM t1
WHERE COALESCE(f1, f2, f3) is not null;

Conclusion:

F F F
- - -
x    
Scroll to Top