title: How to select records with associated IDs but exclude them on the result?
body: <p>I'm encountering a quite confusing logic right now to query some sort of records. Now, I have a table that have various records associated with their <strong>ProductID</strong> and <strong>UserEmail</strong>. I need an exact sql statement to produce the results I need. What I want to do here is to query or fetch sets of records that have <strong>ProductIDs</strong> associated with the <strong>ProductID of that UserEmail and exclude that record with having that particular UserEmail.</strong> See for example, I have a table below and I want to fetch all sets of records with <strong>ProductIDs</strong> that have a <strong>UserEmail = myemail@myemail.com</strong> and exclude that particular record that has that UserEmail.
  I tried some statement using join and I ended up of using this statement but would still return null values.</p>
  
  <pre><code> SELECT DISTINCT ProductID,UserEmail,Comments,UserName FROM [ProdCommentsTab]
      WHERE NOT EXISTS( SELECT ProductID,UserEmail,Comments,UserName FROM [ProdCommentsTab]
      WHERE  UserEmail = @useremail)
  </code></pre>
  
  <p><strong>Table</strong></p>
  
  <pre><code> **ProductID**      **UserEmail**     **UserName**         **Comments**
     c764cbc3      ddgdfh43@yahoo.com    dfgfdhfdhfg     fgshhfdfgh fhdfhhfgj 
     c764cbc3      myemail@myemail.com      MyName      dgsfdhfg fghdfjghj   
     c764cbc3      mitmak84@outlook.com  dgdfgfhfhf   dgsdgdf fghfdhfg 
     f08b9787      dgsdhf23@gmail.com    dfgsdffhhf   dfgsdhf fhfhfhf fhfhfh
     f08b9787      dgsdfgf67@yahoo.com   dgsdgdfhfgh   dfgshf fhdfhg
     f08b9787      myemail@myemail.com     MyName     sdsdgdsgf dfhfhfdg
     f08b9787      sdgsdhf@outlook.com   dgsdgfhfdg    dgsdfhffh fghdjghj
     b1d9dd41      dfsfhfgh45@gmail.com  dsgdfgd       sdgdsgfd fhfdhfg 
     b1d9dd41      myemail@myemail.com      MyName     dgsdhfdg fghdjgj
     e4f9cvd21     sdfgdfdf@yahoo.com    dgsdfhfdfg    dfgshfg fggjgh fghgjg
     e4f9cvd21     sdfdgdf@gmail.com     dfgdshfhf     dfgdhfg fghdfggjg 
  </code></pre>
  
  <p><strong>Output Result</strong> should look like this</p>
  
  <pre><code> **ProductID**      **UserEmail**     **UserName**         **Comments**
     c764cbc3      ddgdfh43@yahoo.com    dfgfdhfdhfg     fgshhfdfgh fhdfhhfgj      
     c764cbc3      mitmak84@outlook.com  dgdfgfhfhf      dgsdgdf fghfdhfg 
     f08b9787      dgsdhf23@gmail.com    dfgsdffhhf      dfgsdhf fhfhfhf fhfhfh
     f08b9787      dgsdfgf67@yahoo.com   dgsdgdfhfgh     dfgshf fhdfhg     
     f08b9787      sdgsdhf@outlook.com   dgsdgfhfdg      dgsdfhffh fghdjghj
     b1d9dd41      dfsfhfgh45@gmail.com  dsgdfgd         sdgdsgfd fhfdhfg 
  </code></pre>