Reputation: 17
how to choose a field with conditions: 1. not null & 2. id = 1 in the same field?
Upvotes: 0
Views: 48
Reputation: 426
You can try IS NOT NULL
SELECT column1,column2
FROM tablename
WHERE id IS NOT NULL AND id=1;
Upvotes: 1
Reputation: 34046
If you just want records with id=1
, then the condition id is NOT NULL
is superflous. You can just write:
SELECT *
FROM table
WHERE id = 1;
If you want records with id is NOT NULL
then id=1
becomes superflous. You can do:
SELECT *
FROM table
WHERE id is NOT NULL;
Upvotes: 1