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

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -