If you had data in table 1 that you need to use to return data in table 2 for each row returned in table 1. What is more efficient to use a set of querys in PHP one inbedded in the while loop of the other or an SQL function within a query?

for example:

```
$qry = mysql_query(SELECT date FROM table1)

while($res = mysql_fetch_array($qry))
{
  $qry = mysql_query("SELECT name FROM table2 WHERE date=$res['date']")
}

```

or to do this as a function that returns the Id from table1 within the query.