Before you even read I wish to thank you for even considering assisting me
Tables:
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"
Query:
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'));









Bookmarks