THIS IS THE INQUIRY:
select asignaturas.materias, estudiantes.id_estudiantes, nombres,apellidos,
calificaciones.id_calificaciones,n1,n2,promedio
from asignaturas,estudiantes,calificaciones where id_calificaciones='$idcaliurl';
Because there is at least one field that is repeated in more than one table, so you must indicate to which table the field belongs. Viewing the query, I think the problem is here: where id_calificaciones
, you must indicate to which table belongs id_calificaciones
I guess it is to the table calificaciones
, therefore, it should be corrected if you put this: where calificaciones.id_calificaciones
.
Also, to avoid future errors of that type, usually indicate which table each column belongs to, even when there is no possibility of repeating them. In that sense, it would also be good to indicate to which table the columns nombres
, apellidos
, n1
, and n2
belong. It is optional, but I usually use the name of the table in the queries involving several tables.
In order not to make the query very long, a custom is to put an alias composed of a letter or two that represent each table. For example, here we give the alias a
for asignaturas
, e
for estudiantes
and c
for calificaciones
.
For example ... here I have course that the columns n1, n2, promedio
belong to the table calificaciones
, if not, you change them for their corresponding table:
SELECT
a.materias,
e.id_estudiantes,
e.nombres,
e.apellidos,
c.id_calificaciones,
c.n1,
c.n2,
c.promedio
FROM
asignaturas a,
estudiantes e,
calificaciones c
WHERE c.id_calificaciones='$idcaliurl';
IMPORTANT NOTE ABOUT SECURITY: Seeing this part of the query:
WHERE c.id_calificaciones='$idcaliurl'
shows a serious security problem. The fact of passing the value$idcaliurl
directly in the query, facilitates the injection of malicious code in your program. You should implement the use of prepared queries.