sql server - Sql Inner join query on condition when specific value -
i have following query:
select art.id, art.nummer, art.serie, art.eanbarcode, art.preis, art.volumen, art.vater, art.name, art.amazon, kat.name, subkat.name, subsubkat.name tbartikel art inner join tbkategorie kat on art.fk_kategorie_id=kat.id inner join tbsubkategorie subkat on art.fk_subkategorie_id=subkat.id inner join tbsubsubkategorie subsubkat on art.fk_subsubkategorie_id=subsubkat.id right(art.nummer,2)='.1'
the situation art.fk_subsubkategorie_id can null (developers did setting 0 instead of null) - knows bad habit how is. want make if there 0 art.fk_subsubkategorie_id want take record , subsubkat.name put empty string. hope got point.
additional question if possible(ps): there diffrence in condition if do:
where right(art.nummer,2)='.1' art.nummer '%.1'
or even:
where not right(art.nummer,2)='.1' art.nummer not '%.1'
i know working indexes, talking whether in case both work , search same? using specific articles.
try this;
select art.id, art.nummer, art.serie, art.eanbarcode, art.preis, art.volumen, art.vater, art.name, art.amazon, kat.name, subkat.name, isnull(subsubkat.name,'') tbartikel art inner join tbkategorie kat on art.fk_kategorie_id=kat.id inner join tbsubkategorie subkat on art.fk_subkategorie_id=subkat.id left outer join tbsubsubkategorie subsubkat on art.fk_subsubkategorie_id=subsubkat.id right(art.nummer,2)='.1'
Comments
Post a Comment