Let's say I've got three tables -
<div style="margin-left:20px">
Requests:
RequestID
RequestName
Categories:
CategoryID
CategoryName
Requests_Categories:
RequestID
CategoryID
</div>
It's easy to write a query that joins the tables and returns a row for each Request/Category relationship. Is
it possible, however, to create a view or query that will return one record for each request with a column for
each category?
So if you had five categories (A - E), and a request fell into three of those categories, the result set would
look something like this:
<table>
<tr
style="font-weight:bold"><td>RequestID</td><td>RequestName</td><td>A</td><td>B</td><td>C</td><td>D</td><td>E</t
d></tr>
<tr><Td>1</td><td>MyRequest</td><td>Y</td><td>N</td><td>Y</td><td>Y</td><td>N</td></tr>
</table>
Ideally the query would dynamically create the columns for categories. So if another category was added the
query wouldn't have to be changed.
Any help would be appreciated.</td>
<div style="margin-left:20px">
Requests:
RequestID
RequestName
Categories:
CategoryID
CategoryName
Requests_Categories:
RequestID
CategoryID
</div>
It's easy to write a query that joins the tables and returns a row for each Request/Category relationship. Is
it possible, however, to create a view or query that will return one record for each request with a column for
each category?
So if you had five categories (A - E), and a request fell into three of those categories, the result set would
look something like this:
<table>
<tr
style="font-weight:bold"><td>RequestID</td><td>RequestName</td><td>A</td><td>B</td><td>C</td><td>D</td><td>E</t
d></tr>
<tr><Td>1</td><td>MyRequest</td><td>Y</td><td>N</td><td>Y</td><td>Y</td><td>N</td></tr>
</table>
Ideally the query would dynamically create the columns for categories. So if another category was added the
query wouldn't have to be changed.
Any help would be appreciated.</td>