MySQL Forums
Forum List  »  Newbie

Problematic SQL statement
Posted by: Duncan O'Sullivan
Date: September 08, 2004 04:01PM

I am trying to extract information from a database that contains data on the links between nodes in a network. The table of interest (linktable) consists of a list of nodes and a list of the links related to each node.

Node Link

node1 link1
node3 link1
node1 link2
node1 link3
node2 link3
node3 link3
node2 link4
node2 link5
node2 link6
node2 link8
node4 link8
node3 link7
node4 link9
node4 link10


I am trying to find the links between nodes in the form ‘Node’ – ‘Node’ ‘Link’ for example given that I want to find all the links involving node3 I can use

SELECT node, compound
FROM linktable
WHERE node <> ‘node3’
AND link = ANY (SELECT link FROM linktable WHERE node = ‘node3’));

Which returns

Node Link

Node1 link1
Node1 link3
Node2 link3

Which is correct, what I would link to find now is all the links between the nodes that have been missed, in this case there is a link between node1 and node2 of link type link3.

Can anyone help with the SQL for such a statement?

Options: ReplyQuote


Subject
Written By
Posted
Problematic SQL statement
September 08, 2004 04:01PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.