Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access thread: select * from table where field Like '*BMW*';


Message #1 by Dean Pan <dpan999@y...> on Wed, 2 May 2001 08:25:10 -0700 (PDT)
Hi!  I am a college student and I ran into this problem.



I use TOMCAT and MS Access to do a course project, and 

I have a function to search through one of table field

named "description" to match string users entered.  I

used MS Access SQL to test the following SQL statement

and it worked, yet when I used the following statement 

in my *.jsp file, it couldn't do anything right except

I used a exact string in my database.  

For example, '*bmw*' would return two records having

"BMW Z3" and "2001 BMW 740il" using MS Access SQL tools.

Yet, *.jsp only take either 'bmw z3' or '2001 bmw 740il'

and '*bmw*' returned no record.



ResultSet myResultSet = stmt.executeQuery("SELECT * FROM auctionItem 

where auctionItem.description Like '" + itemDesp + "'");



It seems to me that JDBCODBC caused the problem.

Anyone can point out where the problem is or the sites

I can find some more infos.



Thanks!



Dean



__________________________________________________

Do You Yahoo!?

Yahoo! Auctions - buy the things you want at great prices

http://auctions.yahoo.com/

Message #2 by Imar@S... on Wed, 2 May 2001 17:56:15
Hi there,



Depending on the driver you use and the way you connect, you may want to 

add a wildcard like * or % to your search term, like this:



    auctionItem.description Like '%" + itemDesp + "%'");



or



    auctionItem.description Like '*" + itemDesp + "*'");



Usually Access will require this wildcard to find anything else than the 

exact sting.



HtH



Imar







> Hi!  I am a college student and I ran into this problem.

> 

> I use TOMCAT and MS Access to do a course project, and 

> I have a function to search through one of table field

> named "description" to match string users entered.  I

> used MS Access SQL to test the following SQL statement

> and it worked, yet when I used the following statement 

> in my *.jsp file, it couldn't do anything right except

> I used a exact string in my database.  

> For example, '*bmw*' would return two records having

> "BMW Z3" and "2001 BMW 740il" using MS Access SQL tools.

> Yet, *.jsp only take either 'bmw z3' or '2001 bmw 740il'

> and '*bmw*' returned no record.

> 

> ResultSet myResultSet = stmt.executeQuery("SELECT * FROM auctionItem 

> where auctionItem.description Like '" + itemDesp + "'");

> 

> It seems to me that JDBCODBC caused the problem.

> Anyone can point out where the problem is or the sites

> I can find some more infos.

> 

> Thanks!

> 

> Dean

> 

>

Message #3 by Dean Pan <dpan999@y...> on Wed, 2 May 2001 23:39:02 -0700 (PDT)
Thanks for the help!



I tried both approaches and found out that MS Access's Query only takes



'*bmw*'



Using *.jsp JDBC-ODBC connect MS Access need to have standard SQL Like

which is '%bmw%'.



Dean

--- Imar@S... wrote:

> Hi there,

> 

> Depending on the driver you use and the way you connect, you may want to 

> add a wildcard like * or % to your search term, like this:

> 

>     auctionItem.description Like '%" + itemDesp + "%'");

> 

> or

> 

>     auctionItem.description Like '*" + itemDesp + "*'");

> 

> Usually Access will require this wildcard to find anything else than the 

> exact sting.

> 

> HtH

> 

> Imar

> 

> 

> 

> > Hi!  I am a college student and I ran into this problem.

> > 

> > I use TOMCAT and MS Access to do a course project, and 

> > I have a function to search through one of table field

> > named "description" to match string users entered.  I

> > used MS Access SQL to test the following SQL statement

> > and it worked, yet when I used the following statement 

> > in my *.jsp file, it couldn't do anything right except

> > I used a exact string in my database.  

> > For example, '*bmw*' would return two records having

> > "BMW Z3" and "2001 BMW 740il" using MS Access SQL tools.

> > Yet, *.jsp only take either 'bmw z3' or '2001 bmw 740il'

> > and '*bmw*' returned no record.

> > 

> > ResultSet myResultSet = stmt.executeQuery("SELECT * FROM auctionItem 

> > where auctionItem.description Like '" + itemDesp + "'");

> > 

> > It seems to me that JDBCODBC caused the problem.

> > Anyone can point out where the problem is or the sites

> > I can find some more infos.

> > 

> > Thanks!

> > 

> > Dean

> > 

> 

  Return to Index