Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / July 2004

Tip: Looking for answers? Try searching our database.

question about the "where ... like ... " clause in SQL

Thread view: 
Marcolm - 23 Jul 2004 13:43 GMT
I want to list all the products name of which begins with ":pdName".

parameterRow.setString("pdName",jTextField_pdName.getText());

queryDataSet_srchAll.setQuery(ne
com.borland.dx.sql.dataset.QueryDescriptor(database_hsmng, "select
from onSale where productName like :pdName" + "%"+";", parameterRow,
true));

Unfortunately, above code takes no effect and my heart sinks to th
benthal.
Anyone knows how can it be done?
Thanks in advance
-
Marcol
-----------------------------------------------------------------------
Murray - 23 Jul 2004 15:10 GMT
> I want to list all the products name of which begins with ":pdName".
>
[quoted text clipped - 9 lines]
> Anyone knows how can it be done?
> Thanks in advance.

Well I'm not familiar with the classes you're using here, but I'm guessing
it's something like a PreparedStatement except it's using named parameters
instead of indexed params?

Think what this will look like: "where productName like :pdName" + "%"+";"
Those + symbols are useless, it's just String concatenation so it will
simply come out as "where productName like :pdName%;". It doesn't work
because no parameter called "pdfName%" exists. You need to append the '%'
symbol to the value, not the parameter name.

parameterRow.setString("pdName",jTextField_pdName.getText() + "%");
lukes - 23 Jul 2004 15:58 GMT
Marcolm <Marcolm.19unpn@mail.codecomments.com> wrote at Pt, 23 lip
2004 12:43:10 GMT:

> I want to list all the products name of which begins with ":pdName".
>
[quoted text clipped - 4 lines]
> from onSale where productName like :pdName" + "%"+";", parameterRow,
> true));

queryDataSet_srchAll.setQuery(new
com.borland.dx.sql.dataset.QueryDescriptor(database_hsmng, "select *
from onSale where productName like ':pdName%';", parameterRow,
true));

shouldnt text be in quotation-marks ( 'exampl%' ) ?

Signature

pozdrowka
lukes



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.