Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with wildcard in query

Status
Not open for further replies.

joy1978

Programmer
May 23, 2003
1
0
0
CA
Hi all,

I need to retrive records where a particular id is in a field. This field has more than one code in each record (seperated by commas) so I used the like operator and then tried both *'s (syntax error) and %'s (invalid character) to make sure i get the code nop matter where it is in the record. Below is my code, this seems straight forwward, am I doing something wrong?
Thanks in Advance
Tara

if( Request( &quot;SLRN_ID&quot; ) <> &quot;&quot; ) then
sql = &quot;SELECT [Drawing Detail File].StNo, [Drawing Detail File].*, [Drawing Type Master File].DwgTypeD &quot; & _
&quot;FROM [Drawing Detail File] INNER JOIN [Drawing Type Master File] ON [Drawing Detail File].DwgType = [Drawing Type Master File].DwgType &quot; & _
&quot;WHERE ((([Drawing Detail File].SLRN_ID) Like '&quot; % & Request( &quot;SLRN_ID&quot; ) & % &quot;' )) AND (([Drawing Detail File].DwgType)='PP' Or ([Drawing Detail File].DwgType)='ES') AND (([Drawing Detail File].Scan)=Yes) &quot;
'response.write sql
 
&quot;WHERE ((([Drawing Detail File].SLRN_ID) Like '% &quot; & Request( &quot;SLRN_ID&quot; ) & &quot;%' ))

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rich Cook
 
I'm totally new to ASP, but know a little SQL. I think you'll have a problem with:

sql = &quot;SELECT [Drawing Detail File].StNo, [Drawing Detail File].*, ...

because the variable &quot;StNo&quot; specified in: [Drawing Detail File].StNo is also included in: [Drawing Detail File].*

Usually, you can't have 2 variables named the same thing.

I think you just want:
sql = &quot;SELECT [Drawing Detail File].*, ...

Hoping to help,
Bev

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top