如何选择postgresql中的col1 = 0 OR col2 = 0 OR col3 != null
语句?
var query = 'SELECT * FROM "Media" WHERE "MediaId" = $1 AND ("AType" = 0 OR "BType" = 0 OR "C" != null)';
CREATE TABLE IF NOT EXISTS "Media"(
"MediaId" SERIAL NOT NULL,
"AType" integer,
"BType" integer,
"C" varchar,
PRIMARY KEY ("MediaId")
);
MediaId | AType | BType | C
0 | 0 | | |
1 | 1 | | |
2 | 2 | | |
3 | | 0 | |
4 | | 1 | |
5 | | | 'f' |
答案 0 :(得分:2)
SELECT * FROM "Media"
WHERE "MediaId" = $1
AND ("AType" = 0 OR "BType" = 0 OR "C" is not null)
您应该使用is not null
代替!=null