Wrox Home  
Search P2P Archive for: Go

  Return to Index  

sql_language thread: [sql_language]using Like


Message #1 by Dean Pan <dpan999@y...> on Wed, 2 May 2001 09:21:29 -0700 (PDT)
Can some one help?

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
--- Donna Collins <dcollins_92117@y...> wrote:
> Select distinct A.*, B.*
> from A inner join B on A_indexfieldname=B_indexfieldname
> 
> When the dbf's are joined, the distinct command evaluates data based on 
> the joined condition.
> 
> Thanks,
> Donna
> 
> > A table has a key field, and fields A & B.  Some records have the same
> > values for A & B.  For example:
> > 
> > A                        B
> > 1                         2
> > 1                         1
> > 3                         2
> > 2                         1
> > 
> > I want to set up a query which only returns one record for each value.  I
> > tried:
> > 
> > SELECT DISTINCT tbl.A, tbl.B
> > FROM tbl
> > WHERE tbl.A<>"" or tbl.B<>"";
> > 
> > Problem is that this returns some identical recordsets:
> > 
> > 1
> > 3
> > 2
> > 2
> > 1
> > 
> > The SQL statement evaluates for distinct on each field, not on both, so I
> > get duplicates.  If I used:
> > WHERE tbl.A<>"" and tbl.B<>""; the recordset would be missing "3".
> > 
> > Any suggestions?  Currently I'm using Access and ASP, but will move to 
> SQL
> > Server at some point.
> > 
> > Thanks in advance,
> > 
> > Mike
> > 
> 
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/

  Return to Index