Groups > DB2 > DB2 on AS400 server > Re: Wildseek




Wildseek

Wildseek
Wed, 26 Dec 2007 16:15:37 +010
Hi,

We converted a dbf based app to a db2 based app

We have 1 problem

We had a 'Wildseek' functionality in this app which means you type in a seek 
value in a textbox, and the app goes to the database and looks in all fields 
where this value occurs

How do we do this in a sql way

Thanks in advance

Peter
Belgium



Post Reply
Re: Wildseek
Thu, 27 Dec 2007 07:42:10 EST
You want to use the LIKE clause of a SELECT statement.  For example;<br
/>
<br />
SELECT &lt;fields&gt; FROM &lt;table&gt; WHERE
&lt;column&gt; LIKE '%somevalue%'<br />
<br />
The % act as wildcard characters so the above will find all rows that have
'somevalue' anywhere within the column.<br />
<br />
Post Reply
Re: Wildseek
Thu, 27 Dec 2007 14:07:54 EST
Hi,<br />
<br />
it's not a nice solution either, but you may use a query that resembles the
following:<br />
<br />
Select *<br />
  from MyTable<br />
  Where Col1 concat Col2 concat Col3 ... concat ColN like '%MYVAL%'<br />
<br />
To avoid hardcoding, you may build your SQL statement dynamically by reading
through the SysColumns Catalog view stored in the QSYS2 library.<br />
<br />
Post Reply
Re: Wildseek
Thu, 27 Dec 2007 14:58:38 +010
Thanks,

I know this, but I would like to search in all the collums
The user does not know in which column he finds the info

Is this possible

Thanks
<mwagoner@wildflavors.com> wrote in message 
news:2128453456.1198759360768.JavaMail.wassrvr@ltsgwas009.sby.ibm.com...
> You want to use the LIKE clause of a SELECT statement.  For example;<br
/>
> <br />
> SELECT &lt;fields&gt; FROM &lt;table&gt; WHERE
&lt;column&gt; LIKE 
> '%somevalue%'<br />
> <br />
> The % act as wildcard characters so the above will find all rows that have

> 'somevalue' anywhere within the column.<br />
> <br />
> The select will be case-sensitive, so you may have to convert it to upper 
> or lower case. 

Post Reply
Re: Wildseek
Fri, 28 Dec 2007 09:04:58 +010
birgitta,
thanks

I will try this

Peter
"B.Hauser" <BrgttHsr@aol.com> wrote in message 
news:267918810.1198782504906.JavaMail.root@ltsgwas010.sby.ibm.com...
> Hi,<br />
> <br />
> it's not a nice solution either, but you may use a query that resembles 
> the following:<br />
> <br />
> Select *<br />
>  from MyTable<br />
>  Where Col1 concat Col2 concat Col3 ... concat ColN like '%MYVAL%'<br
/>
> <br />
> To avoid hardcoding, you may build your SQL statement dynamically by 
> reading through the SysColumns Catalog view stored in the QSYS2 
> library.<br />
> <br />
> Birgitta 

Post Reply
about | contact