I have a script in which I have a large number of blogs. There are several posts on these blogs. Each blog post can link to a blog post in another blog, but then they should not link back to this blog to the link blog.
To clarify:
- Site A links to Site B (and may link to other sites)
- Site B then cannot link to Site A (but can link to other sites).
Each time a message is created, I save the message identifier and the identifier of the website to which it refers. It is important to remember that as soon as one post is linked to any mail on another website, the other website cannot link anywhere , not just the message with which it is linked.
Site A can link to Site B as many times as he likes, and each message can link to several other messages. An example scenario could be:
- Site A Link to Site B
- Site C links to site B
- Site D links to site A
In the above data:
- Site A may again link to site C (or site B)
- Site B may link to site D
- Site C may link to site A or site D (or site B again).
- Site D may link to site B or site C (or site A again).
Here is a link to some test data and a dump of the two tables:
http://pastie.org/1506715
I think I need a cross-connection to get all possible combinations of links, but then a factor in the existing relationship so that the sites do not link back in the opposite direction. The query that I still have is:
SELECT
t1.* , t2.* FROM test_posts t1, test_posts as t2
WHERE
t1.post_id != t2.post_id
ORDER BY
t1.post_id, t2.post_id;
. , , , , . test_smartlinks_to_websites, post_id - "originating" - site_id, "destination" (, -, ).
NOT EXISTS, ( ).