468,321 Members | 1,686 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,321 developers. It's quick & easy.

Combine keyword and search result ?

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
3 28160
mentor
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
2,878 Expert 2GB
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
mentor
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.

Similar topics

1 post views Thread by lfjca | last post: by
1 post views Thread by howard w | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.