Article View: bit.databases.mssql-l
Article #208Re: sql search keyword
From: Brad McFarlane
Date: Mon, 24 Feb 2003 18:35
Date: Mon, 24 Feb 2003 18:35
27 lines
2024 bytes
2024 bytes
exist_world_beyond_yours wrote:
>
> Hello, I'm trying to search for particular word inside VARCHAR (not
> entire phrase) but
>
> WHERE
> CIRCUIT.TABLE.NAME LIKE :keyword
>
> only work for the entire phrase. Ex. " i go to java class" , search key
> want to be consider match "java"
>
> How do I code it in java?
>
> ResultSet results = statement.executeQuery("SELECT * FROM CIRCUIT.TABLE
> WHERE CIRCUIT.TABLE.NAME LIKE *"+keywordz+"*"); /* doesn't work */
>
> Thank you for reviewing
IIRC, the SQL wildcard character is "%" not "*", so I'd write the query
as:
"SELECT * FROM CIRCUIT.TABLE WHERE CIRCUIT.TABLE.NAME LIKE '%" +
keywordz + "%'" (and note that the whole pattern is enclosed in single
quotes).
Hope this helps/works,
Brad
Technical Details
Message-ID:
<3E5A6608.762100A0@alcatel.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!snoopy.risq.qc.ca!News.Dal.Ca!torn!webster!nf1.bellglobal.com!kannews.ca.alcatel.com!kannews.ca.alcatel.com!not-for-mailReferences:
<3e5a621d_1@news.tm.net.my>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f5d71,e6cac314263c9233 X-Google-Attributes: gidf5d71,public X-Google-Thread: f6611,e6cac314263c9233 X-Google-Attributes: gidf6611,public X-Google-Thread: 10f47b,e6cac314263c9233 X-Google-Attributes: gid10f47b,public X-Google-ArrivalTime: 2003-02-24 10:50:27 PST From: Brad McFarlane <brad.mcfarlane@alcatel.com> Newsgroups: bit.databases.mssql-l,comp.databases.ibm-db2,comp.lang.java Subject: Re: sql search keyword Date: Mon, 24 Feb 2003 13:35:52 -0500 Organization: Alcatel Canada Lines: 27 Message-ID: <3E5A6608.762100A0@alcatel.com> References: <3e5a621d_1@news.tm.net.my> NNTP-Posting-Host: umrk-pc.ca.newbridge.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: kannews.ca.alcatel.com 1046111755 19821 138.120.127.181 (24 Feb 2003 18:35:55 GMT) X-Complaints-To: news@ca.alcatel.com NNTP-Posting-Date: 24 Feb 2003 18:35:55 GMT X-Mailer: Mozilla 4.61 [en] (WinNT; U) X-Accept-Language: en Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!snoopy.risq.qc.ca!News.Dal.Ca!torn!webster!nf1.bellglobal.com!kannews.ca.alcatel.com!kannews.ca.alcatel.com!not-for-mail