Problem with table hits

This is a query to the database to fetch messages that the user has sent to other users.

The problem is that I need to get the first and last name, and they are in another table. Under the name (datacenter).

id_finish(id of the person to send messages to) is a foreign key to the id field of the datacenter table.

The datacenter has name, surname fields, which I need to somehow include in this loop

So how do I do something $row[4]; and $row[5]; had name and surname from datacenter table

   $select = mysql_query("SELECT id, text, avatar, id_finish,  FROM massage WHERE id_start = '$id'");
  while ($row = mysql_fetch_array($select))
  echo $row[0];
echo $row[1];
echo $row[2];
echo $row[3];

Answer 1


SELECT id, text, avatar, id_finish, name, surname FROM massage m join datacenter d
on = m.id_finish WHERE id_start = ‘$id’