If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Help with strings and sql

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-15-04, 09:53
slidj slidj is offline
Registered User
 
Join Date: Mar 2004
Posts: 11
Help with strings and sql

I m having a serious problem with the syntax for some string operations. What i want to do is, for example, to take a string from a text box that is a question, eg. "where is tower bridge", and i want to be able to recognise the part of the string 'where' in the question and compare the 'london bridge' with a list of sights in a db.

for example in pseudo code:

if question CONTAINS 'where is' and 'sights'

reply = "'sight' is near 'tube station'

can anyone help me with this dillema?
many thanks in advance
Reply With Quote
  #2 (permalink)  
Old 03-15-04, 13:53
gyuan gyuan is offline
Registered User
 
Join Date: Dec 2003
Posts: 454
I'm not very clear to your question, but I think that you can use the function

InStr(string1, string2)

to check if the string2 exists in string1.
Reply With Quote
  #3 (permalink)  
Old 03-15-04, 15:24
slidj slidj is offline
Registered User
 
Join Date: Mar 2004
Posts: 11
thanks for your reply, i was finding it hard to explain sorry!

i have been working on this all day,

ive got a question that is entered into a text box, eg. where is london bridge.

and ive realised that using instr i can find out where london bridge is in the sentence, if i have:

question = "where is london bridge"
Response.Write InStr(question,"london bridge")

but as you can see i have to know what the sight is to construct the statement, i want to have something like:

question = "where is london bridge"
Response.Write InStr(question,rs("sights"))

where the question is compared against a list of sights in a database. but i dont know what the correct syntax is or if there is a better way of doing it.
Reply With Quote
  #4 (permalink)  
Old 03-15-04, 16:52
gyuan gyuan is offline
Registered User
 
Join Date: Dec 2003
Posts: 454
If I do not mis-understand your question, you want to know if the question entered by the user contains some words which are stored in database. For this case, you need a LOOP to find if the words is in the question.

<%
Do While Not theRS.EOF
If InStr(question, RS("sights")) > 0 Then
'*** do something here ***
End If
Loop
%>
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On