|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Result substitution in query when null (not COALESCE)Folks
I have a typical Parent / Child table relationship. I have a field that is always present in Parent but only sometime in Child (the idea is to override de Parent value for a specific Child line). Now I'd like to query Child and, when the said field is null, have it's value replaced by the value in Parent. I'm not quite sure that this is possible using a query but a stored proc might be the trick ? That being said I have no idea how to tackle this... Any help appreciated ! --alexT Why not COALESCE (or ISNULL) ?
SELECT COALESCE(child.property, parent.property) as Something FROM Child C INNER JOIN Parent P ON C.ParentId= P.id Show quote "AlexT" <goo***@atc.ch> wrote in message news:1124434021.394538.133650@o13g2000cwo.googlegroups.com... > Folks > > I have a typical Parent / Child table relationship. > > I have a field that is always present in Parent but only sometime in > Child (the idea is to override de Parent value for a specific Child > line). > > Now I'd like to query Child and, when the said field is null, have > it's value replaced by the value in Parent. > > I'm not quite sure that this is possible using a query but a stored > proc might be the trick ? That being said I have no idea how to tackle > this... > > Any help appreciated ! > > --alexT > |
|||||||||||||||||||||||