-- to be executed for 1 time only! drop temporary table if exists linklist; create temporary table linklist( srcNodeId int unsigned not null, dstNodeId int unsigned not null, primary key(srcNodeId, dstNodeId) ) engine=MEMORY select link.srcNodeId, link.dstNodeId from nodeLinkT link join allowedNodeLinkByNodeV anln on link.srcNodeId = anln.srcNodeId and link.dstNodeId = anln.dstNodeId where link.metric > 1 and anln.singleSrc = 'y'; /* select n1.*, n2.* from linklist ll join nodeT n1 on ll.srcNodeId = n1.id join nodeT n2 on ll.dstNodeId = n2.id; */ set @1 = nodeLink_UpdateStart(); select __nodeLink_Create(null, srcNodeId, dstNodeId) from linklist; set @2 = nodeLink_UpdateEnd(); drop temporary table linklist;