MySQL resolves all joins using a single-sweep multi-join method. This means that MySQL reads a row from the first table, and then finds a matching row in the second table, the third table, and so on. When all tables are processed, MySQL outputs the selected columns and backtracks through the table list until a table is found for which there are more matching rows. The next row is read from this table and the process continues with the next table.
foreach (rowA in tableA)
{
foreach (rowB in tableB where col1=rowA.col1)
{
foreach (rowB in tableC where col1=rowA.col2)
{
out<< ...
}
}
}