title: Multiple selects and comparisons in sql
body: <pre><code>String sql = "
      SELECT NAME, 
             SURNAME, 
             ORDERID, 
             CUSTOMERID, 
             PRIORITY, 
             STATUS, 
             DATE, 
             TIME 
      FROM ORDERS O 
      WHERE O.CUSTOMERID IN "
              + "(SELECT LOGGEDIN 
                  FROM CUSTOMERS 
                  WHERE LOGGEDIN=1)";
  </code></pre>
  
  <p>I have two tables one called customer and one called orders. In my customer table I want to retrieve all the people who are currently logged in to the system and then match this with my orders table to see if they currently have any orders pending as well. Both of these tables contain a customerid column which contain the same values. However, I am not sure how to use and carry out the logged in check all in one statement. Above is one of the attempts that I have made which is currently incorrect as it needs to add a join for the customerid's but I am unsure who to carry this out. In addition, the sql driver that I am using is Apache Derby in case anyone was wondering</p>