tags:

views:

58

answers:

2

I have the following tables and fields:

+------------------+  +-------------------+  +---------------+
| Request          |  | RequestItem       |  | Item          |
+------------------+  +-------------------+  +---------------+
| + Requester_Name |  | + Request_No      |  | + Item        |
+------------------+  +-------------------+  +---------------+
| + Request_No     |  | + Item            |
+------------------+  +-------------------+

I would like to filter the items which are selected under a particular request number, along with a specific requester name. How might I go about doing this?

+1  A: 

In SQL? Of course I haven't tested this, but what about:

SELECT items
FROM item INNER JOIN requestitem ON item.items = requestitem.item
WHERE requestitem.request_no = Whatever_Request_Number_You_Want

Or how about:

SELECT items
FROM item INNER JOIN requestitem ON item.items = requestitem.item
INNER JOIN request ON requestitem.request_no = request.request_no
WHERE request.requester_name = 'Whatever_Name_You_Want'
Matt Blaine
Note: Field name (and table name) is "item", not "items" in the original question.
Oddthinking
Yeah but from the **first** revision of the original question: "UNDER ITEM TABLE I HAVE A FIELD CALLED ITEMS"; http://stackoverflow.com/revisions/161f51f2-1404-4495-9865-8daa49a7ce64/view-source
Matt Blaine
+1  A: 

Making some assumptions about what the data looks like, but here's a try:

SELECT item
FROM requestitem
    JOIN item ON requestitem.item = item.item
    JOIN request ON requestitem.request_no = request.request_no
WHERE
    request.request_no = 8642
    AND request.requester_name = 'Specific J. Requester';
bignose