Help for this page

Select Code to Download


  1. or download this
    users
      user_id
    ...
        LEFT JOIN parent_user_rlt as p2c ON p2c.parent_id = parent.user_id
        LEFT JOIN users as child ON child.user_id = g2p.child_id
      ;
    
  2. or download this
      SELECT distinct parent_id FROM grandchildren;
      SELECT grandparent_id, count(distinct parent_id) FROM grandchildren 
    +GROUP BY grandparent_id;
      SELECT grandparent_id, parent_id, count(*) as num_kids FROM grandchi
    +ldren GROUP BY grandparent_id, parent_id;
      SELECT child_id, child_first, child_last FROM grandchildren;