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

Combine keyword and search result ?

P: 24
Supposed col1 has been indexed,
Expand|Select|Wrap|Line Numbers
  1. SELECT col1, col2 FROM table1 WHERE col1 CONTAINS ( key1 OR key2 OR key3)
will return col1, col2. Now I want to relates the results with each keyword, i.e, to clarify which result corresponds to which keyword.

How to do this?

Can we get the following results?

Expand|Select|Wrap|Line Numbers
  1.    key1, col1, col2;
  2. key1, col1, col2;
  3. key2, col1, col2
For performance reason, WHILE or FOR loop is not considered.
Feb 14 '08 #1
Share this Question
Share on Google+
3 Replies


P: 24
Correct the code above:

Supposed col1 has been indexed,
Expand|Select|Wrap|Line Numbers
  1. SELECT col1, col2 FROM table1 WHERE CONTAINS (col1, (  key1, key2, key3))
will return col1, col2. Now I want to relates the results with each keyword, i.e, to clarify which result corresponds to which keyword.

How to do this?

Can we get the following results?

Expand|Select|Wrap|Line Numbers
  1.    key1, col1, col2;
  2. key1, col1, col2;
  3. key2, col1, col2
For performance reason, WHILE or FOR loop is not considered.
Feb 14 '08 #2

ck9663
Expert 2.5K+
P: 2,878
Basically, you want to include the key on the query that matches. However, I noticed that you only check the keys against col1, but you included col2 on your desired result. What if the keymatches col1 (since it's on the WHERE clause), but not col2? Do you still want it returned, like your second row in your desired results?

-- CK
Feb 14 '08 #3

P: 24
Thanks. That's what I want. It's been solved.

Basically, you want to include the key on the query that matches. However, I noticed that you only check the keys against col1, but you included col2 on your desired result. What if the keymatches col1 (since it's on the WHERE clause), but not col2? Do you still want it returned, like your second row in your desired results?

-- CK
Feb 14 '08 #4

Post your reply

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