Results 1 to 16 of 16
Jan 13, 2005, 14:09 #1
- Join Date
- Jan 2005
- 0 Post(s)
- 0 Thread(s)
Tri-purpose "XREF Table" trouble
Before you even read I wish to thank you for even considering assisting me
Content - id, name.....
Cross - c, t, crosstype (XREF Table)
ContentType - id, title....
I need to XReference elements from 2 different tables to each other, and to each of themselves in one XREF table.
So...I set it up for Cross.type to define if an XREF table entry was a...
0 -> ContentType <-> ContentType (to group types)
1 -> Content <-> ContentType (for defining what kind of content)
2 -> Content <-> Content (for relating content)
...type of cross reference.
My ContentType table is filled with entries like "news", "downloads", and "old".
My Content table is filled with entries like "News Update 12-04-22 - Blahblahahl"
SELECT `content`.`id`, `content`.`title` FROM `content`,`cross`
//This next line finds Content that has a cross reference with a ContentType item identified by "A_TYPE_ID"
WHERE (`content`.`id` = `cross`.`c` AND `cross`.`t` = 'A_TYPE_ID' AND `cross`.`crosstype` = '1')
//The next group finds if the Content item "A_CONTENT_ID" is cross referenced with the content.id found previously.
AND ((`content`.`id` = `cross`.`c` AND `cross`.`t` = 'A_CONTENT_ID' AND `cross`.`crosstype` = '2')
OR (`content`.`id` = `cross`.`t` AND `cross`.`c` = 'A_CONTENT_ID' AND `cross`.`crosstype` = '2'));
Last edited by The PC Nerd; Jan 15, 2005 at 17:06.