#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Posts
    1
    Rep Power
    0

    Search Rows from a table which has two words


    Hi,

    to find two words in a row of table when the first word must precede the second word by a specified number of words. (NOTE: PRE represents precedes and n represents the number of words from 1 to 255.)

    EXAMPLE: behavioral PRE/3 disturbances would find articles in which behavioral precedes disturbances by three or fewer words.


    Kindly reply me ASAP.

    Thanks & Regards
    Abhishek Jain
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Posts
    48
    Rep Power
    3
    Have you tried using Regular expressions?

    I am not that expert in regular expressions, therefore can't think of it, but for these kind of queries, regular expression an help you.

    you can search Google for getting a ready made regular expression or there are tools available (for which also u will need to search) that help to create a regular expression.
  4. #3
  5. DEVILS IN RED
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2005
    Location
    Kerala, India
    Posts
    200
    Rep Power
    10
    Use the wildcard character "_"(underscore) and the "LIKE" clause. So "behavioral %___ disturbances" would get the result for you.

    You can get more help here:
    http://dev.mysql.com/doc/refman/5.0/...-matching.html
    Ahmed Shefeer
  6. #4
  7. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,118
    Rep Power
    4274
    Originally Posted by Shefeer
    So "behavioral %___ disturbances" would get the result for you.
    no, sorry

    that would work only if behavioral was at the very left and disturbances was at the very right, and there was a stretch of three consecutive characters between them

    what the original poster wanted was three or fewer words -- emphasis on words
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

IMN logo majestic logo threadwatch logo seochat tools logo