Combine keyword and search result ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mentor
    New Member
    • Mar 2007
    • 24

    Combine keyword and search result ?

    Supposed col1 has been indexed,
    Code:
    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?

    Code:
       key1, col1, col2;
    key1, col1, col2;
    key2, col1, col2
    For performance reason, WHILE or FOR loop is not considered.
    Last edited by mentor; Feb 14 '08, 05:42 AM. Reason: not clear
  • mentor
    New Member
    • Mar 2007
    • 24

    #2
    Correct the code above:

    Originally posted by mentor
    Supposed col1 has been indexed,
    Code:
    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?

    Code:
       key1, col1, col2;
    key1, col1, col2;
    key2, col1, col2
    For performance reason, WHILE or FOR loop is not considered.

    Comment

    • ck9663
      Recognized Expert Specialist
      • Jun 2007
      • 2878

      #3
      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

      Comment

      • mentor
        New Member
        • Mar 2007
        • 24

        #4
        Thanks. That's what I want. It's been solved.

        Originally posted by ck9663
        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

        Comment

        Working...