Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: how to search multiple columns?
If your current query gives you want you want (appart from the column)
you could do something like this:-
select score,
project_id, case when instr(objectives,'search term',1,1) > 1 then
'Objectives'
when instr(objectives,'search term',1,1) > 1 then
'Approach'
when instr(scope,'search term',1,1) > 1 then 'Scope' when instr(title,'search term',1,1) > 1 then 'Title' end
This may not be the best suggestion, as depending on how many rows are returned, and how much data is in each of the cols, it could be slow. If you are displaying search results, say 10 at a time, then you could limit the results of the inner select to 10 rows, and the outer select should be alright. Note that it doesn't cater for the case when the search term could appear in more than one of the cols.
Ignore my comment on Bind vars if you are using this approach - I was refering to the dynamic sql option.
Stephen. Received on Wed Jul 27 2005 - 10:03:06 CDT
![]() |
![]() |