I have this query to generate a datatable of last payments in a web
$query ="SELECT * FROM wp_ac_sesiones LEFT JOIN wp_ac_clientes ON wp_ac_sesiones.id_usuario = wp_ac_clientes.id_usuario";
I only need the Join to show me the name and surname of the person, then I create the rows
<td>'.$row["id"].'</td>
<td>'.$row["nombre"].'</td>
<td>'.$row["apellidos"].'</td>
<td>'.$row["fecha"].'</td>
<td>'.$row["clases_aumentadas"].'</td>
<td>'.$row["precio"].'</td>
<td>'.$row["comentario"].'</td>
But it takes the data from wp_ac_clientes and when it does not have it, from wp_ac_sessions when I need the id that it shows me to be that of the payment, not that of the user. I do not understand where the error could be, I have tried with different types of JOIN but the same thing happens to me in all of them, from wp_ac_clientes I only need the name and surname.
You can in the select make an alias to each table and then only bring the necessary fields and not all (*) as you are doing now.