T SQL Multiple Table Query
Posted on 2013-06-06
Hi, Just need a little help with an SQL query please.
I have a table 'StageExtensions' which has the following columns
The idea of this table is that it defines a number of Attributes for a Stage. I also have an associated table EventStageDetailValue which has the following columns
The idea here is that the EventStageDetailValue table holds value for a specific EventStage and Stage Type. My problem is that this table may or may not have values but I always want to be able to display the headings. Essentially I want a query similar to
SELECT StageExtensions.Name, EventStageDetailValue.*
LEFT JOIN EventStageDetailValue ON EventStageDetailValue.StageExtensionID = StageExtensions.ID
WHERE StageID = 1 AND EventStageDetailValue.EventStageDetailID = 4
The problem with this query is that it does not return the headings from the StageExtensions table if there are no values in the SEventStageDetailValue table.
To be more specific, if the StageExtensions table contains entries for Name and Age I want the query to return rows for Name and Age as well as (any) Value from the EventStageDetailValue table.