Extending question
Fastest way to find not null filed in sqlite
I have table structure
CREATE TABLE IF NOT EXISTS [app_status](
[id] INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL ,
[status] TEXT DEFAULT NULL,
[type] INTEGER
)
Where type value either can be one or two.
First I want to check if there is no row where type is equal to 1 and having status as not null.
It it fails I want to check if there is no row where type is equal to 2.
For that I have written two sql query.
SELECT 1
FROM [app_status]
WHERE [status] IS NOT NULL
AND [type]=1
if it doesn’t return any row I fires
SELECT 2
FROM [app_status]
WHERE [status] IS NOT NULL
AND [type]=2
Is there a way to merge these condition in one query.
Returning one if any row having non null status and type 1 if not returning 2 any row having not null status type 2.
otherwise returning 0 ?
Why not:
?
Do you need all the duplicates?