I have a table with columns start\_date and end\_date. What we need to do is Select everything and group them by date conflicts for each Object\_ID. 

A date conflict is when a row's start date and/or end date pass through another rows'. For instance, here are some examples of conflicts:

Row 1 has dates 1st through the 5th, Row 2 has dates 2nd through the 3rd.

Row 1 has dates 2nd through the 5th, Row 2 has dates 1st through the 3rd.

Row 1 has dates 2nd through the 5th, Row 2 has dates 3rd through the 6th.

Row 1 has dates 2nd through the 5th, Row 2 has dates 1st through the 7th.

So for example, if we have some sample data (assume the numbers are just days of the month for simplicity):

```
id | object_id | start_date | end_date
1  | 1         | 1          | 5
2  | 1         | 2          | 4
3  | 1         | 6          | 8
4  | 2         | 2          | 3

```

What i would expect to see is this:

```
object_id | start_date | end_date | numconflicts
1         | <na>       | <na>     | 2
1         | 6          | 8        | 0 or null
2         | 2          | 3        | 0 or null

```

And for a Second Test Case, Here is some sample data:

```
id | object_id | start_date | end_date
1  | 1         | 1          | 5
2  | 1         | 2          | 4
3  | 1         | 6          | 8
4  | 2         | 2          | 3
5  | 2         | 4          | 5
6  | 1         | 2          | 3
7  | 1         | 10         | 12
8  | 1         | 11         | 13

```

And for the second Test Case, what I would expect to see as output:

```
object_id | start_date | end_date | numconflicts
1         | <na>       | <na>     | 3
1         | 6          | 8        | 0 or null
2         | 2          | 3        | 0 or null
2         | 4          | 5        | 0 or null
1         | <na>       | <na>     | 2

```

Yes, I will need some way of differentiating the first and the second grouping (the first and last rows) but I haven't quite figured that out. The goal is to view this list, and then when you click on a group of conflicts you can view all of the conflicts in that group.

My first thought was to attempt some GROUP BY CASE ... clause but I just wrapped by head around itself. 

The language I am using to call mysql is php. So if someone knows of a php-loop solution rather than a large mysql query i am all ears.

Thanks in advance.

Edit: Added in primary Keys to provide a little less confusion. 

Edit: Added in a Test case 2 to provide some more reasoning.