Note that there are some explanatory texts on larger screens.

plurals
  1. POGet mutually and non mutually existening Fields in same table in Two columns
    primarykey
    data
    text
    <p>This is a question similar to another question I posted <a href="https://stackoverflow.com/questions/2444109/how-to-check-for-mutual-existence-of-fields-in-same-table-in-two-columns">here</a> but is a little different. <br><br> I am trying to get a list of all instances of mutual and non-mutual existing Users. <br> What I mean is that the returned result from the query will return a list of users along with their co-worker. <br> It is similar to the question <a href="https://stackoverflow.com/questions/2444109/how-to-check-for-mutual-existence-of-fields-in-same-table-in-two-columns">here</a>, but the difference is that non mutual users will be returned too and with out the "duplicity" mutually existing users return in the list (See image below in-order simplify it all). <br> <br> I took the original answer from <a href="https://stackoverflow.com/questions/2444109/how-to-check-for-mutual-existence-of-fields-in-same-table-in-two-columns/2444442#2444442">Thomas</a> (Thanx again Thomas) <br> <code>Select D1.u_username, U1.Permission, U1.Grade, D1.f_username, U2.Permission, U2.Grade<br>from tblDynamicUserList As D1<br>&nbsp; &nbsp; Join tblDynamicUserList As D2<br>&nbsp; &nbsp; &nbsp; &nbsp; On D2.u_username = D1.f_username<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; And D2.f_username = D1.u_username<br>&nbsp; &nbsp; Join tblUsers As U1<br>&nbsp; &nbsp; &nbsp; &nbsp; On U1.u_username = D1.u_username<br>&nbsp; &nbsp; Join tblUsers As U2<br>&nbsp; &nbsp; &nbsp; &nbsp; On U2.u_username = D2.u_username<br></code> <br> and after several trials I commented out 2 lines (Below). <br> The returned results are what I am trying to accomplish, as described in the beginning of this question, except for the "duplicity" returned by mutually existing users in the table. <br> How can I eliminate this duplicity? <br> <br> <code>Select D1.u_username, U1.Permission, U1.Grade, D1.f_username, U2.Permission, U2.Grade<br>from tblDynamicUserList As D1<br>&nbsp; &nbsp; Join tblDynamicUserList As D2<br>&nbsp; &nbsp; &nbsp; &nbsp; On D2.u_username = D1.f_username<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* And D2.f_username = D1.u_username <em>/<br>&nbsp; &nbsp; Join tblUsers As U1<br>&nbsp; &nbsp; &nbsp; &nbsp; On U1.u_username = D1.u_username<br>&nbsp; &nbsp; Join tblUsers As U2<br>&nbsp; &nbsp; &nbsp; &nbsp; On U2.u_username = D2.u_username<br> /</em> WHERE D1.U_userName &lt; D1.f_username */ <br> </code> <br> *Screenshot that hopefully helps explain it all. <br> <a href="http://www.marketing2go.co.il/SqlQuestion.jpg" rel="nofollow noreferrer">http://www.marketing2go.co.il/SqlQuestion.jpg</a> <br></p> <p>Here are the results of the updated query (with the 2 lines commented out) <br> <a href="http://www.marketing2go.co.il/QueryResults.jpg" rel="nofollow noreferrer">http://www.marketing2go.co.il/QueryResults.jpg</a> <br> The required results should be without rows 1 and 2 (or without rows 3 and 5), because they are in effect, a duplicity. That is because that pair exist in rows 3 and 5 (the order of the names in each pair is irrelevant). <br> For a lack of a better word, it's more like a logical duplicity. <br></p> <p>Many thanx in advance <br></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload