search - How do I structure a SELECT query for the following -


Hopefully anyone here will be able to provide some mysql advice ...

I I'm working on a clear search system: I have tables like:

Exercise Exercise Exercise Title SEARCHTAGS searchtagID parentID (-> searchtag) searchtag EXERCISESEARCHTAGS exerciseID (foreign key - & gt; Practice) searchtagID (foreign key -> SEARCHTAGS)

The search tag can be arranged in an arbitrary deep tree. So, for example, I may have a tree of search tag that looks like this ...

  head of head of body parts elbow leg hip knee muscles Pecus byes trips  

now ...

I want to select all search tags in a branch of the tree which is in a subset of records referenced by a single searchag in a different branch of the tree Gives reference to at least one record.

For example, suppose the search tag points to a subset of "arm" exercises, if any reference to any of that subset is referenced by the search tag from the "fleshy" branch of SEARCHTAGS. , So if I want to select them, my query may return "biceps", "triceps".

Two questions:

1) How does any kind of selection query look like this? (If such a thing is possible even without very slow speed, then I'm not sure where it is starting ...)

2) Do I need to touch my datastructure to make sure Should do something for

Thank you in advance for your help, it is much appreciated.

Alternatively, use, which is also known. This requires two fields (left and right) instead of one (parent ID), and makes some tasks difficult, but makes whole branches much easier.


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -