QUERY with 2 columm linked to a same table??

Angelo

Registered User.
Local time
Yesterday, 20:35
Joined
Feb 25, 2010
Messages
10
Hi,

I must do a query searching from a table (A) that return some columms (columm 1, columm 2, columm 3...) that linked to another table (B).

The problem is I have 3 columms linked to the same table. I have to return a name from table (B) into 3 columms at table (A).

Tkx!!
 
You can add table B into your query design multiple times, access will give each seperate instance of the table a unique alias which you can use to join to your table A
 
I tried this...

Code:
SELECT tb_Receber.nCdCompetencia, tb_Empresa.cClienteFantasia, tb_Receber.nCdEmpresaID, tb_Empresa.cRazaoSocial
FROM tb_Empresa 
 
INNER JOIN tb_Receber 
 
ON (tb_Receber.nCdEmpresaID = tb_Empresa.nClienteID) 
 
AND (tb_Empresa.nClienteID = tb_Receber.nCdCompetencia);

And didn't work!
 
I think your table structure must be an issue.

Here is SQL equivalent to the SQL in your post
Code:
SELECT tb_Receber.nCdCompetencia
, tb_Empresa.cClienteFantasia
, tb_Receber.nCdEmpresaID
, tb_Empresa.cRazaoSocial
FROM tb_Empresa 
, tb_Receber 
WHERE (tb_Receber.nCdEmpresaID = tb_Empresa.nClienteID) 
AND (tb_Empresa.nClienteID = tb_Receber.nCdCompetencia);

which would mean that
tb_Receber.nCdCompetencia must equal tb_Receber.nCdEmpresaID

which doesn't seem right.

Why not tell us the table structures including keys?
Good luck
 

Users who are viewing this thread

Back
Top Bottom