Question: I have two tables Bag and Item. 

The bag table consists of the metadata for the bag. The item table consists of what items are in the bag and the quantity of that item. 

I am trying to see if I can find any bags that have a laptop and a tablet. For reference I have `ItemType` which is the Item name, and `BagID` for the bag id:

```
SELECT Item.BagID, Item.ItemType
FROM 
  Bag INNER JOIN 
  Item ON Bag.BagID = Item.BagID
WHERE ItemType = 'Tablet' AND ItemType = 'Laptop';

```

I tried this but since thats not how the tables work this query wont work. 

Any help would be greatly appreciated.

Answer: 
You can try a query with two `EXISTS` clauses:

```
SELECT * FROM Bag b
WHERE 
  EXISTS (SELECT * FROM Item i
          WHERE ItemType = 'Tablet' AND b.BagID = i.BagID)
  AND EXISTS (SELECT * FROM Item i 
              WHERE ItemType = 'Laptop' AND b.BagID = i.BagID)

```

Alternatively, you can join `Bag` to `Item` table twice:

```
SELECT * 
 FROM 
  Bag b INNER JOIN 
   item laptop ON laptop.ItemType = 'Laptop' AND laptop .BagID = b.BagID INNER JOIN
   item tablet ON tablet.ItemType = 'Tablet' AND tablet .BagID = b.BagID;

```

First query will return one row per bag with tablets and laptops in it, while second query might return several rows if you have more than one row of laptop and/or tablet it items for a bag.
I like to approach these types of queries using `group by` and `having`. In MS Access, this looks like:

```
SELECT Item.BagID
FROM Bag INNER JOIN
     Item
     ON Bag.BagID = Item.BagID
WHERE ItemType IN ('Tablet', 'Laptop')
GROUP BY Item.BagID
HAVING COUNT(Item.BagId) = 2;

```

Note: this assumes that two items of the same time are not in the bag.