Advertisement

08.01.2007 at 02:08PM PDT, ID: 22735965 | Points: 250
[x]
Attachment Details

SQL ho to retrieve multiple records form table1 linked to table 2

Asked by samassrl in Informix Database, SQL Query Syntax

Tags: multiple, sql, retrieve, records, from

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
SamassrlStart Free Trial
[+][-]08.01.2007 at 02:20PM PDT, ID: 19612983

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.01.2007 at 02:27PM PDT, ID: 19613017

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.02.2007 at 02:12PM PDT, ID: 19620929

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32