ecco cosa ho scritto come query (prendendo spunto dall'esempio)
Codice PHP:
SELECT p.*, (select count(*) from patient_visit as p1 where p1. id_patient=p. id_patient) as Num_Visite
FROM patient p
INNER JOIN patient_visit pc ON pc.id_patient = p.id_patient
ORDER BY p.id_patient
Per comodità ho scritto p.* per prelevare tutti i valori dalla tabella Patient
Ho il seguente errore:
Codice PHP:
SQL Error: no such column: p.id_patient <SELECT p.*, (select count(*) from patient_visit as p1 where p1. id_patient=p. id_patient) as Num_Visite FROM patient p INNER JOIN patient_visit pc ON pc.id_patient = p.id_patient ORDER BY p.id_patient
Ovviamente il campo id_patient in Patient esiste (è la chiave primaria).