Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL - Any data in this column?
elziko wrote in message <3e2feee3$0$2562$afc38c87_at_news.easynet.co.uk>...
>I want to check a ceratin column to see if it has any data for a certain
ID.
>So I'm using this SQL:
>
>SELECT count(mycolumn)
>FROM mytable
>WHERE myid = 10
>AND mycolumn IS NOT NULL
>
>If that returns a number greater than zero I know there is data in the
>column. However, for my situation this is too slow. Is there a faster way?
>
>Cheers,
>
>elziko
>
How about using 'exists' which will stop looking as soon as it finds a value:
SELECT 'Found value'
FROM dual
WHERE EXISTS (SELECT 1
FROM mytable WHERE myid = 10 AND mycolumn IS NOT NULL)
Steve E. Received on Fri Jan 24 2003 - 05:59:15 CST
![]() |
![]() |