问题描述:

I have the following Situation:

t1

------

| id |

|----|

| 1 |

| 2 |

| 3 |

| 4 |

------

t2

----------------------

| id | pid | current |

|----|-----|----------

| 1 | 1 | 1 |

| 2 | 1 | NULL |

| 3 | 2 | NULL |

| 4 | 3 | 1 |

| 5 | 4 | NULL |

| 6 | 4 | 1 |

----------------------

Expected Result:

---------

| t1.id |

|-------|

| 1 |

| 2 |

---------

In Words:

I want to select every t1, which has ( only one child with current IS NULL ) or ( at least 2 children, where there is at least one child with current IS NULL and a higher id than the one with current NOT NULL )

all the best

相关阅读:
Top