I make my real case more simple.
The case:
There are multiple curves they are passed in points and each of them have final 1 point.The final point represented in database as biggest point_order value of the curve.
Should be find curves that pass in specific point and have same final point (same point_id)
The case(tables):
point table:
point_id|x|y
Edit:
curve_points table example - find all curves that have same point_id=80 and same final point:
id|curve_id|point_id|point_order
|119 |6 |12
|119 |80 |9
|119 |1000 |1
|76 |80 |7
|76 |6 |9
|76 |2 |2
|90 |80 |7
|90 |6 |9
|90 |99 |15
Output result should be:
|curve_id|
|119 |
|76 |
Because the curves 119,76 have same final point=6 and have same point 80. Curve 90 not because the point 6 not his final point
psedocode function - need to add code for choose same final point:
function findCurvesForSamePointAndSameFinalPoint(pointID){
query="SELECT curve_id FROM curve INNER JOIN point GROUP BY curve_id HAVING point_id="+pointID+";";
return getDATABASEResult(query);
}
Edit2: online sql with some data to test:http://sqlfiddle.com/#!2/59e9f/1 (the existed query there not works)
Thanks