开发者

Update TAG Relational table from select match on main table with keywords field and tag table with individual keywords

I imported the Software PAD File Database from http://paddatabase.net/download.html into Microsoft Access in a table called main:

MAIN
-----
ID
ProgramName
Keywords
.
.

I created two new tables: Tags and TagSoftwareRel.

Tags
--------
ID
Tag


TagSoftwareRel
--------------
ID
SoftwareID <- (MainTable)
TagID <- tags table

I extracted all the keywords from the field Keywords as individual words in the Tags table. They Keywords field from Main looks like this:

Keywords
Paul, animated, moving monk, paulaner
Image,Imaging,Graphics,Rotate,Resize,Effects,
Sharpen,Blur,JPEG,TIFF,BMP,WBMP,PSD,GIF,PDF,Format,ICM,ICC,CMYK,
thumbnail,Convert,Display,AJAX,AVI,red-eye removal,lossless JPEG  transform     
correction, rich,internet,applications,ebooks,webmaster,authoring,

What I want to do is create a SQL Query which Inserts the tagID from the tags table into tagsoftwarerel.tagid and the related softwareID from the main table into tagsoftwarerel.softwareid by using a where tags.tag like main.keyword开发者_Python百科s

I'm sort of at loss of where to start with this.

As it is a public DB I can provide a copy of the database to anyone interested.

Any assistance would be most appreciated. Thank you.


I assume that the field ID from the TagSoftwareRel is an autovalue or identity. That means the value is created automaticly by inserting a new row: I understand that you already filled the Tags-Table.

Here is a query which would fill the TagSoftarerel-Table:

Insert into TagSoftarerel (SoftwareID, TagID)
Select m.Id, 
       (Select T.TagId from Tag T where T.Tag = m.Keyword) as TagId 
from MAIN m 

Advice: I think you could find a better solution. The Tag-information is redundant in your solution. If you would just add the Tag.Id to the main-table you could get rid of the Keyword column and store the tag-information solely in the tag table, where it belongs to.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜