Keyword mapping

  • I have two tables setup where one contains a list of keywords and category The second table contains actual data description. By mapping the keywords on the Data description column, we will have to update the respective category.

    Can we achieve the same using a Query or we have to write a Procedure?

  • Please provide sample tables, data, and expected output. We can't do much for you without that as a starting point. Also, I don't understand your question about query or procedure...

    Best,
    Kevin G. Boles
    SQL Server Consultant
    SQL MVP 2007-2012
    TheSQLGuru on googles mail service

  • Hi,

    I am here by attaching a sample excel workbook where we have two worksheets, one represents the first table and second worksheet represents the issues table which needs to be updated on the category column based on the Keywords available in the Keywords table.

    As this is a sample, we have few rows.. in reality there are more than a lakh of rows in the Issues table.

    My query was with regards to a SQL query with which we can update the categories on the Issues table based on the Keywords table.

    Thanks,

    Ram240582

  • I don't open excel spreadsheets from the web.

    Sorry, I wasn't specific enough in my request. I (and others that might help you) need CREATE TABLE scripts (temporary tables please, not permanent ones) and INSERT ... scripts that we can run directly on SQL Server to use to build a query that can help solve your problem. We need your expected outputs from the given inputs so we can really understand what you mean/need.

    Best,
    Kevin G. Boles
    SQL Server Consultant
    SQL MVP 2007-2012
    TheSQLGuru on googles mail service

  • If this is a one-off you could do:

    UPDATE issues

    SET category = (SELECT MIN (k.category)

    FROM keywords k

    WHERE i.description LIKE '%' + k.keyword + '%')

    FROM keywords k

    I will be really slow.

    If you need to do this on a regular basis, you need to consider full-text indexing.

    [font="Times New Roman"]Erland Sommarskog, SQL Server MVP, www.sommarskog.se[/font]

  • Ram240582 (8/27/2013)


    I have two tables setup where one contains a list of keywords and category The second table contains actual data description. By mapping the keywords on the Data description column, we will have to update the respective category.

    Can we achieve the same using a Query or we have to write a Procedure?

    Welcome aboard. To get better and quicker answers in the future, most likely with a coded example that actually works, please see the first link in my signature line below.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply