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!

Why SQL Return only one record with "Like"?

Status
Not open for further replies.

Tivoli0

MIS
Dec 7, 2001
41
0
0
IL
Hi all friends,

Why do I get only one record return with these "Like" clause? I know I have more than one record of that one author or body. In fact, the query pulls only the most recent one.
Code:
    <%
    if request.form(&quot;keywordBody&quot;) <> &quot;&quot; then
       SQL = &quot;SELECT * FROM articles WHERE body LIKE '%&quot; & Request.Form(&quot;keywordBody&quot;) & &quot;%'&quot;
  
    else
       SQL = &quot;SELECT * FROM articles WHERE author LIKE '%&quot; & Request.Form(&quot;keywordAuthor&quot;) & &quot;%'&quot;
  
    end if

%>

Can anyone shed some light on this behavior?

Thanks much! -Tivoli0
 
try using a variable :
-------------------------------------
<% Dim myVAR
myVAR=&quot;Request.Form(&quot;KeywordBody&quot;)&quot;
%>
<%
IF myVAR <> &quot;&quot; THEN
SQL = &quot;SELECT * FROM articles WHERE body LIKE '%&quot; & myVAR & &quot;%'&quot;
ELSE
Response.Write(&quot;Type something in the filed Keyword&quot;)
%>
-------------
hm just another thought....SELECT DISTINCT vs. SELECT *

All the best!
 
Are you looping through the recordset?

Try printing out the sql string instead of sending it to the database, then copy and paste it into the query analyzer that is part of your particlur db and see what results you get back.

-Tarwn

[sub]01010100 01101001 01100101 01110010 01101110 01101111 01101011 00101110 01100011 01101111 01101101 [/sub]
[sup]29 3K 10 3D 3L 3J 3K 10 32 35 10 3E 39 33 35 10 3K 3F 10 38 31 3M 35 10 36 3I 35 35 10 3K 39 3D 35 10 1Q 19[/sup]
Do you know how hot your computer is running at home? I do
 
Thanks for the prompt reply!

You were right, I had to loop thru the recordset...
boy, shows you how banged up I am...! Thanx again!

-Tivoli0
 
sorry Tivolio I just assumed you didn't want to post the rest of the code and that you have been goign through the records...but u got it and that is what counts~
:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top