Retrieve matched values

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Archanak
    New Member
    • Sep 2006
    • 79

    Retrieve matched values

    Hi,

    I have table like this:

    Code:
    select * from sampletest;
    
    | title                                                                                                                                                                                                                               | description                                                                                                                                                                                                                                                                                                                    |
    +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    | AWK was probably second after Snobol a string processing language that extensively use regular expressions.                                                                                                                         | In 1985, just before Perl, a new version made the programming language more powerful, introducing user-defined functions, multiple input streams, and computed regular expressions. The version in System V Release 4 added some new features and also cleaned up the behavior in some of the ``dark corners' of the language. |
    | WWW has dramatically raised the visibility of Perl in recent years -- to certain extent at the expense of TCL and other Unix-based scripting languages, although WEB also produced several Perl competitors like JavaScript and PHP | Due to the Web Perl has become one of major programming languages for Internet practically like VB dominates Windows arena, Perl now dominates CGI scripts                                                                                                                                                                     |
    +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    2 rows in set (0.00 sec)
    I have query terms submitted by user like this:

    query1= regular AND expressions

    query2=regular AND (expressions OR AWK)

    I want to match ( title and description both) with these query terms and retrieve the matched title and descriptions.

    I have created fulltext on title and description.

    I am not getting how to form a select query which satisfies the above criteria!!!

    Output should be like this:

    Code:
    AWK was probably second after Snobol a string processing language that extensively use regular expressions [ in title]
    
    In 1985, just before Perl, a new version made the programming language more powerful, introducing user-defined functions, multiple input streams, and computed regular expressions. The version in System V Release 4 added some new features and also cleaned up the behavior in some of the ``dark corners' of the language [in description]
    Basically i want to retrieve the matched contents with the given queryterms.

    I tried like this for title only but i don't know how to combine both title and description.

    Code:
    select title from sampletest where title RLIKE '[[:<:]]regular[[:>:]]' and title RLIKE '[[:<:]]expression[[:>:]]' :]]';
    
    +-------------------------------------------------------------------------------------------------------------+
    | title                                                                                                       |
    +-------------------------------------------------------------------------------------------------------------+
    | AWK was probably second after Snobol a string processing language that extensively use regular expressions. | 
    +-------------------------------------------------------------------------------------------------------------+
    1 row in set (0.01 sec)
    How can i combine title and description match the queryterms and retrieve???


    How can i do this?

    Regads
    Archana
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    To match for both title and description you just use AND on the where clause.
    To combine returned results you just add them together using CONCAT.

    Is that what you want?

    Comment

    • Archanak
      New Member
      • Sep 2006
      • 79

      #3
      Originally posted by r035198x
      To match for both title and description you just use AND on the where clause.
      To combine returned results you just add them together using CONCAT.

      Is that what you want?
      Hi,

      Ya in a way like that!!!

      Can u tell me the query???

      can u explain more !!!

      I just want to retrieve title and description of the matched query (query1= regular AND expressions query2=regular AND (expressions OR AWK))

      I should check either title or description that has these queryterms.

      It can be in one or it can be in both also!!!

      How to do that???

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        It can be in one or it can be in both also!!!
        If this is your condition then you simply check in title or description, no need to check in both.
        Code:
        where (title LIKE someCrypticStuffHere OR description like evenMoreCrypticStuff)
        OR (title like 'AWK%'   OR description like 'AWK%'

        Comment

        • Archanak
          New Member
          • Sep 2006
          • 79

          #5
          Originally posted by r035198x
          If this is your condition then you simply check in title or description, no need to check in both.
          Code:
          where (title LIKE someCrypticStuffHere OR description like evenMoreCrypticStuff)
          OR (title like 'AWK%'   OR description like 'AWK%'
          Hi,

          But the order is changed.

          I have AND operator in between the queryterms how can i handle that??

          I have another example query3=regular AND perl AND (expressions OR AWK))

          In such case the order becomes very important.

          I want to retrieve title OR description (both) that has all terms i.e regular, perl expressions OR awk!!

          How can i do that?

          Comment

          Working...