title: Query to only show user data from their group based on login table
body: <p>We currently have apps for each office that only shows those that log in data from their office, right now that means having a separate app for each office, which means if we make application changes I have to update 20 different apps.</p>
  
  <p>The logins are done through APEX with a custom authentication scheme that only allows a person to login if the office designation matches the app.</p>
  
  <p>What I would like to figure out is how I can write the sql query that when a person logs in they only see the data from their office so I can get down to one application instead of having an app for each office.</p>
  
  <p>Here's the structure of the table that contains the logins.</p>
  
  <pre><code>    "PKEY" NUMBER, 
      "USERNAME" VARCHAR2(50), 
      "PASSWORD" VARCHAR2(50), 
      "NAME" VARCHAR2(50), 
      "EMAIL" VARCHAR2(50), 
      "OFFICE" VARCHAR2(50), 
       CONSTRAINT "LOGINS_PK" PRIMARY KEY ("PKEY")
  </code></pre>
  
  <p>And here's code from one of the current queries that's used to bring up office submittal information.</p>
  
  <pre><code>    select "PKEY", 
  "DATE_SUB",
  "CLIENT",
  "CANDIDATE",
  "RECRUITER",
  "CONTACT",
  "SALES",
  dbms_lob.getlength("RESUME") "RESUME",
  "MIMETYPE",
  "FILENAME",
  "POSITION",
  "AVAILABILITY",
  "RATE",
  "ISSUES",
  "WHEN_INT",
  "FEEDBACK",
  "REQ_PRIORITY",
  "OFFICE",
  "NOTES",
  "REJECT",
  "INT_FB"
  from "SUBS"
  WHERE "OFFICE" = 'OFFICE1'
  AND ("REJECT" = 'Accepted' or "REJECT" IS NULL)
  AND SALES != 'House'
  </code></pre>
  
  <p>What I'm trying to figure out is how I can use the "OFFICE" field in the logins table and compare that against the "OFFICE" field in the "SUBS" table so that APEX only shows results to a user that contains the same "OFFICE" designation that's in the logins table.</p>
  
  <p>Example: User Joe Smith logs in as jsmith and he's in OFFICE1, so when he logs in he'll only see data that contains OFFICE1 in the OFFICE field in the table. User Jane Brown logs in to the same app as jbrown and she's in OFFICE2 so she only sees the data that has OFFICE2 in the OFFICE field.</p>
  
  <p>Thanks for all the help in advance!</p>