Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Jezvon

Pages: [1]
1
I have a query that joins 3 tables and I am trying to retrieve a conditional set of rows depending on whether the record exists in the third table.

If there is a match in the 3rd table then I just want the matching records from the 1st table. if there isn't a match from the 3rd table then I just want one record from the first table.

Code: [Select]
select o.Object_ID,
reqCon.Connector_ID,
req.Object_ID as Requirement_ID

from t_object o

left join t_connector reqCon on reqCon.End_Object_ID = o.Object_ID and reqCon.Stereotype = 'deriveReqt'
left join t_object req on reqCon.Start_Object_ID = req.Object_ID and req.Stereotype = 'functionalRequirement'

This produces the following type of result, but the ones highlight with the > ... < are the actual rows that are required.
Object_IDConnector_IDRequirement_ID
4093643259
4093643260
>409364329938013<
4094343264
4094343265
>409434329838014<
>4408846245<
4408846246
>4266944655<
4266944656
>4267044657<
4267044658

Pages: [1]