By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,846 Members | 1,544 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,846 IT Pros & Developers. It's quick & easy.

Retrieve matched values

P: 79

I have table like this:

Expand|Select|Wrap|Line Numbers
  2. select * from sampletest;
  4. | title                                                                                                                                                                                                                               | description                                                                                                                                                                                                                                                                                                                    |
  5. +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  6. | 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. |
  7. | 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                                                                                                                                                                     |
  8. +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  9. 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:

Expand|Select|Wrap|Line Numbers
  2. AWK was probably second after Snobol a string processing language that extensively use regular expressions [ in title]
  4. 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.

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

How can i do this?

Feb 12 '09 #1
Share this Question
Share on Google+
4 Replies

P: 13,264
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?
Feb 13 '09 #2

P: 79

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???
Feb 13 '09 #3

P: 13,264
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.
Expand|Select|Wrap|Line Numbers
  1. where (title LIKE someCrypticStuffHere OR description like evenMoreCrypticStuff)
  2. OR (title like 'AWK%'   OR description like 'AWK%'
Feb 13 '09 #4

P: 79

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?
Feb 13 '09 #5

Post your reply

Sign in to post your reply or Sign up for a free account.