SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Keyword mapping


Keyword mapping

Author
Message
Ram240582
Ram240582
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
Points: 2 Visits: 9
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?
TheSQLGuru
TheSQLGuru
SSChampion
SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)

Group: General Forum Members
Points: 12421 Visits: 8548
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
Ram240582
Ram240582
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
Points: 2 Visits: 9
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
Attachments
Mapping.xlsx (14 views, 9.00 KB)
TheSQLGuru
TheSQLGuru
SSChampion
SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)

Group: General Forum Members
Points: 12421 Visits: 8548
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
Erland Sommarskog
Erland Sommarskog
SSCrazy
SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)

Group: General Forum Members
Points: 2113 Visits: 872
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.

Erland Sommarskog, SQL Server MVP, www.sommarskog.se
Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)

Group: General Forum Members
Points: 85953 Visits: 41091
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.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search