I'm working on a project and have come to a block. I can't seem to figure out how I can get results based on multiple rows. For example, consider a basic scheme If we join these tables using the stuff_id field as the common factor, each row will have a single type_name and type_value. However, we may have multiple type_names and type_values associated with any given stuff.id, so we get multiple rows. What is the simplest way to determine which stuff.id items match more than one condition for type_name / type_value pairs? For example, SELECT id FROM stuff WHERE (type_name1 > some_value) AND (type_name2 > some_value2) Of course, the above query will not work, but hopefully it explains what I am trying to do. I want to search based on type_names and type_values, but allow multiple to be specified (and joined by either "and" or "or" statements. "or" is straightforward because we just get multiple rows with our results, but "and" I cannot figure out) I am trying to obtain all IDs where the conditions are met. The problem is that I allow for any number of conditions (at least one, based on type_name/type_value pairs) to be specified, and the various type_names grows dynamically as well (thus we cannot simply make a column for type_name1, type_name2, etc in the stuff table - if we could the select statement would be trivial). Another way to think about it is: How can I have multiple conditions on type_name / type_value pairs and return those that match and have the same stuff_id (without knowing stuff_id, this is what we want to obtain)? Any ideas from anyone able to understand my confusing question?