Hi experts,
I have 2 tables
one is made of
id
values
docid
reference
the other one has several fields
...
serial
...
reference in table 1 is linked to serial in table 2
now I need to retrieve the field value in table 1 where docid=1 and docid=2
I need to have something like:
[field1].....[fieldn] from table 2 + [value1], [value2] where value 1 and value2 are the fields in table 1 with docid=1 and docid=2 and reference=serial
is it possible to do it in one sql statement?
Please let me know if it is not clear enough
PS this is the real sql I am executing
SELECT s_pazienti.data, pazienti.nominativo, pazienti.sesso,pazienti. telefono, pazienti.usl, pazienti.cartella, datidoc_car.valore, pazienti.reparto
FROM datidoc_car LEFT JOIN (a_pazienti INNER JOIN (pazienti INNER JOIN s_pazienti ON
pazienti.seriale = s_pazienti.codice) ON
a_pazienti.seriale = pazienti.codice) ON
datidoc_car.riferimento = pazienti.seriale
WHERE ( s_pazienti.servizio=18 )
AND ( datidoc_car.codice=23 )
AND ( pazienti.tipo in ('D','H') )
AND ( pazienti.stato='A' )
group by 8,7,5,6,4,3,2,1
order by reparto, valore DESC, s_pazienti.data
in the same query I need to retrieve datidoc_car.valore for datidoc_car.codice=8
thanks
Samassrl
Start Free Trial