Wednesday, March 21, 2012

Problems with null values

Im having problems creating a query.
I have a table with the following fields:
patchbayLineout,summary,lineBoxName,effectid,compr essorID,preAmpID,synthID,mixingConsoleID,drumMachi neID.
On the same row as PatchBayLineOut, the part connected there should have its name showing. In the table, the ID is present. For instance, a LineOut that has a Linebox connected contains LineBoxID, and NULL in all the other places.

The output I want is this:

1, Summary text, LB.Name, null, null, null, null, null, null
2, Summary text, null, E.Name, null, null, null, null, null
3, Summary text, null, null, C.Name, null, null, null, null
4, Summary text, null, null, null, PA.Name, null, null, null

Can anyone help me?I think you want to perform a lot of outer joins like this:

select t.id, t.summary, lb.name, e.name, c.name, pa.name, ...
from t
left outer join lb on lb.id = t.lb_id
left outer join e on e.id = t.e_id
... etc.sql

No comments:

Post a Comment