searching more a word in a phrase thru sql

Results 1 to 2 of 2

Thread: searching more a word in a phrase thru sql

  1. #1
    Join Date
    Dec 1969

    Default searching more a word in a phrase thru sql

    okay, i would like to do a simple search from a db, and in the keyword cell of that db i will have more than one word, and the user enters a specific word that is in the keyword cell, but the cell is made out of more than 1 words, how can i know if the word is there?<BR>e.g.<BR>tablecell value=monkeys, birds, flower.<BR>userrequest=birds.<BR>so what kind of sql statement can i use to search all the words of the tablecell, i am using an access db.

  2. #2
    Join Date
    Dec 1969

    Default RE: searching more a word in a phrase thru sql

    You got your answer vestaday,what happened..?<BR>Ok,let&#039;s say you have field "Nature" in table "Earth" <BR> Earth<BR> Nature<BR>monkeys, birds, flower<BR>dog, cat, mice<BR>donkey, potator, onion<BR>..<BR>so,first we need to find rs where we have "flower"<BR>strSQL="Select Nature From Earth Where Nature=&#039;%"&flower&"&#039;"<BR>&#039;in this case we know that we can have only one record <BR>&#039;with "flower",right ?? if yes then:<BR>..<BR>str = rs("Nature")<BR>Response.Write (str)&"&ltbr&gt"<BR> <BR>&#039;then we need to find "flower" in this rs,so we can use split()(Right or mid function if we know for sure the order in rs..)<BR>&#039;we use split()<BR>strArray = split(str,", ")<BR>&#039;commar and space,it&#039;s what you have between words in rs we got<BR>&#039;now we have array of this rs<BR>&#039;then we just loop through it<BR> For i=0 to Ubound(strArray)<BR> If strArray(i)="flower" Then<BR> strFlower = strArray(i)<BR> Response.Write (strFlower)<BR> else<BR> Exit For<BR> end if<BR> Next<BR>&#039;if we know that "flower" is at the end of astring<BR>&#039;we can also do:<BR>str=Ubound(strArray)<BR>Response.Write (str)<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts