I really need help for a OPTIMIZED query:
A challange Q:
There is a way from point A to point B named as ab ( A-->B (ab) )
There is a way from point B to point C named as bc ( B-->C (bc) )
There is no DIRECT WAY from point A to point C
Q :
There are 100 000+ rows contaning way datas of at least for 2 of the point A, B, C (but no A to c)
We are looking for solution (query) for INDIRECT WAY from A to C such that it gives
"There is a way from A to B then from B to C."
Table structure:
| point1 | point2 | way | any_via |
| A | B | a1b1 | b2c2,b1d1,b1e1,b1f1,b2g1... |
| B | C | b2c2 | no-via |
As you see with second row we know that B point is also start point for way a1b1 (from A to 😎
Consider that
there are many ways from a to b named as a1b1, a2b2, a3b3 ... with 100+ any_via in it...
there are many ways from b to b named as b1c1, b2c2, c3b3 ...
But if you think that there are 100 000+ rows it is impossible to handle it...
If really needed we can modify table structure...
Current query:
$query="select way from table where point2='$DEST' "; } // $DEST is what we looking for point2 ie; C
$count = mysql_numrows($query);
$i = 0; while ($i<$count) {
$way = mysql_result($query,$i,"way");
$query2 = mysql_query("select * from table where point1='DEP' and any_via like '%$way%'");
$count2 = mysql_numrows($query2);
$j=0; while ($j<$count2){
$way2 = @mysql_result($query2,$j,"way");
echo $way."i have found a way!";
$j++; }
$i++; }
Thanks in advance...
CK