-
Hi,
I know I've seen this somewhere.
How do I search a table to see if it contains a specific value?
Ex: If I have 1000 names and I want to see if there is anyone named 'Smith'. I don't want to search
the whole table. I want to stop when I find a record with the name 'Smith' and return a value
(0 or 1 I guess) depending on wherther I find it or not.
Thanks
-
If you whant to stop searching after first finding, use the hint /*+first_rows */ in your SELECT query.
-
Select * from emp
where name like '%Smith%'
and rownum = 1
;
-
select 1 from dual
where exists (select 1 from emp where name like '%Smith%' )
union
select 0 from dual
where not exists (select 1 from emp where name like '%Smith%' )
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|