Ok, so let us look at the outcome of just one entry from metainfo:
Code:
attrName attrValue instanceId
timestamp 2013-08-02 16:04:20.142 1
So after getting this entry the next thing you do is link to primarydata based on the instanceid from metainfo and the metaInstanceId in primarydata.
So now for this single entry there are 3 rows in primarydata that have the corresponding id. I will simply show as if we had done select *:
Code:
p.attrName p.attrValue p.metaInstanceId m.attrName m.attrValue m.instanceId
portNum 80 1 timestamp 2013-08-02 16:04:20.142 1
serverName pegasus 1 timestamp 2013-08-02 16:04:20.142 1
inUse F 1 timestamp 2013-08-02 16:04:20.142 1
Lastly you have added a third table which also has 3 entries related to the id = 1 and since there is no way to distinguish from any other line this join will be a product of the current rows
multiplied by the newly added rows, so we end up with:
Code:
p.attrName p.attrValue p.metaInstanceId m.attrName m.attrValue m.instanceId a.result a.metaInstanceId
portNum 80 1 timestamp 2013-08-02 16:04:20.142 1 Pass 1
portNum 80 1 timestamp 2013-08-02 16:04:20.142 1 Pass 1
portNum 80 1 timestamp 2013-08-02 16:04:20.142 1 Fail 1
serverName pegasus 1 timestamp 2013-08-02 16:04:20.142 1 Pass 1
serverName pegasus 1 timestamp 2013-08-02 16:04:20.142 1 Pass 1
serverName pegasus 1 timestamp 2013-08-02 16:04:20.142 1 Fail 1
inUse F 1 timestamp 2013-08-02 16:04:20.142 1 Pass 1
inUse F 1 timestamp 2013-08-02 16:04:20.142 1 Pass 1
inUse F 1 timestamp 2013-08-02 16:04:20.142 1 Fail 1
So as you can see there is no way here to reduce the list of information presented as there is nothing particularly unique about the data you have returned.
Now if primarydata and auditdata were linked on a second id there returned a single unique entry in auditdata for the corresponding id in primarydata, then you would be able to reduce
this to the 3 single entries you seem to be looking for.
So again I say, you need to go back and look at the other fields to find better items to join on or this will be the best you get.
Lastly I would add, the suggestion of using distinct would make the above look like:
Code:
p.attrName p.attrValue p.metaInstanceId m.attrName m.attrValue m.instanceId a.result a.metaInstanceId
portNum 80 1 timestamp 2013-08-02 16:04:20.142 1 Pass 1
portNum 80 1 timestamp 2013-08-02 16:04:20.142 1 Fail 1
serverName pegasus 1 timestamp 2013-08-02 16:04:20.142 1 Pass 1
serverName pegasus 1 timestamp 2013-08-02 16:04:20.142 1 Fail 1
inUse F 1 timestamp 2013-08-02 16:04:20.142 1 Pass 1
inUse F 1 timestamp 2013-08-02 16:04:20.142 1 Fail 1
As there are 2 unique results in each set it will reduce to 6 rows but still not what is required.