|
|
|
How to write it on one query?
|
|||
|---|---|---|---|
|
#18+
I have the following DB: Posts which have an Id, Tags also with Id, and TagsToPosts table which have TagsToPosts.PostId => Posts.Id and TagsToPosts.TagId => Tags.Id FK relations. I need to delete multiple items from TagsToPosts in following way. I'm creating IList<Tag> newTagsby parsing a string. Each tag have it's name. I want to delete all TagsToPosts items pointing to single post (TagsToPosts.PostId == mypostid) and which points to Tag with name which not in mynewTags. For instance I have one post with Id = 1, three tags: 1 => "tag1", 2 => "tag2", 3 => "tag3"And ManyToMany relations table TagsToPosts: 1 => 1, 1 => 2, 1 => 3 So all three tags are linked to my post. After that I'll create a new IList<Tag> newList = new List<Tag>() by parsing a string. newList contains: 0 => "tag1", 0 => "tag2". Now I want to remove third relation from table TagsToPosts because my new list of tags doesn't contain tag with name "tag3". So I need to find a difference. I know I can find similar items using JOIN but how to find difference? I want this to happend in one DB query without iterating over each item to delete it. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 18.03.2009, 11:33 |
|
||
|
|

start [/forum/topic.php?fid=17&tid=1351897]: |
0ms |
get settings: |
11ms |
get forum list: |
17ms |
check forum access: |
2ms |
check topic access: |
2ms |
track hit: |
54ms |
get topic data: |
11ms |
get forum data: |
3ms |
get page messages: |
41ms |
get tp. blocked users: |
2ms |
| others: | 240ms |
| total: | 383ms |

| 0 / 0 |
