Tag filtering Query using T-SQL and Linq-to-SQL?
Posted
by EdenMachine
on Stack Overflow
See other posts from Stack Overflow
or by EdenMachine
Published on 2010-05-02T16:57:41Z
Indexed on
2010/05/02
17:18 UTC
Read the original article
Hit count: 175
linq-to-sql
|tags
I'm trying to figure out how to allow a user to enter in a string of tags (keywords separated by spaces) in a textbox to filter a grid of results.
Here are the tables:
PACKETS
*PacketID
Name
PACKETTAGS
*PacketTagID
PacketID
TagID
Tags
*TagID
Name
Here is the basic query without the WHERE parameters:
SELECT
Packets.Name, Tags.Name AS Tag, PacketTags.PacketTagID
FROM
Packets
INNER JOIN
PacketTags ON Packets.PacketID = PacketTags.PacketID
INNER JOIN
Tags ON PacketTags.TagID = Tags.TagID
I need to filter out all the Packets that don't have tags that match any of the words BUT ALSO ONLY include the Packets that have the tags entered in the string of text (spaces separate the tags when entered into the textbox)
I'm starting with the basics by figuring this out in t-SQL first but ultimately I need to be able to do this in Linq-to-SQL
© Stack Overflow or respective owner