python 2.7 - Query SQL with "childs" -
i'm newbie sql , wondering if i'm going show possible do.
i have table :
b c d ------------------------- 1 1 1 p 1 pf 2 2 2 pf 3 3 3 p 3 p 3 p 3 p 4 4 4 pf 4 pf 5 5 5 p
i query extract fields in column "a" doesn't have "pf" in column "c" same number. i.e.:
b c d ------------------------- 3 3 3 p 3 p 3 p 3 p 5 5 5 p
i'm using python 2.7 , sqlite 3
assuming empty values null, can use coalesce() parent id in each row:
select * mytable coalesce(a, b) not in (select b mytable c = 'pf');
Comments
Post a Comment