On Wed, 11 May 2016 06:26:23 -0400, William Drago
<wdrago at verizon.net> wrote:

> All,
>
> Is there a simple way to find a row in a table where none of 
> columns contain a null value? For example:
>
> SELECT * FROM AnyTable WHERE (all columns IS NOT NULL) LIMIT 1;
>
> Or do I have to do this manually in my application scanning 
> every column in every row until I find a row with no nulls?

You can express your criteria in the WHERE clause, by naming all
columns:

SELECT * FROM AnyTable 
WHERE col1 IS NOT NULL
  AND col3 IS NOT NULL
  AND col3 IS NOT NULL
:
: (etc)
:
LIMIT 1;

Your application could compose the WHERE clause using the output
from PRAGMA table_info(AnyTable) to iterate over all columns.

> Thanks,
> -Bill

-- 
Regards,

Kees Nuyt

Reply via email to