title: How do I add a boolean column to an SQL result set based on comparison with a second table
body: <p>Essentially I have the first part of the question answered and here is the SQL statement I have so far...</p>
  
  <pre><code>SELECT DbaRolePrivs.GRANTEE,
         DbaRolePrivs.GRANTED_ROLE,
         ApplicationRoleDefinition.ROLE,
         ApplicationRoledefinition.description_tx, 
         CASE
           WHEN GRANTED_ROLE = ROLE AND GRANTEE = USERNAME THEN
             'T'
           ELSE
             'F'
         END AS checkMark
  FROM DBA_ROLE_PRIVS DbaRolePrivs, APPLICATION_ROLE_DEFINITION ApplicationRoleDefinition
  </code></pre>
  
  <p>Here is the logic I am trying to perform in plain english.  </p>
  
  <p>"Given a list of all roles and their descriptions, mark each role as TRUE or FALSE based on if the current selected USERNAME has been granted that role based on their own GrantedRoles list."</p>
  
  <p>Right now it is of course returning a double list since the "case when" section compares each of the granted roles with the total list of roles.  (I say duplicate because the test user only has two roles, in the current SQL query it will return a row per granted role for every possible role.</p>
  
  <p>I've barely worked with SQL so I'm more used to C++, Objective-C, etc.  Really all I need in the "case when" section is to check if the current ROLE exists at all in the GRANTED_ROLE column.  I've seen the EXISTS function but that seems to be meant solely for result sets such as "WHERE EXISTS."</p>
  
  <p>Thanks in advance, I know it's probably simple for anyone whose worked with databases often, I've only just started.</p>