Query 1:N

  • Thread starter Thread starter Arturo Guzman
  • Start date Start date
A

Arturo Guzman

Hello i have a problem with a query of the folowing table:

Client

IdClient
Name
Adress
......
IDBANKBUY
IDBANKSELL

Banks

IDBANK
NAME
ADDRESS

IDBANKBUY and IDBANKSELL is relationed to IDBANK, so I need to get the
client data (Name,Address) and the name of the bank where the client
buys and sells.

Im using Access 2003.

Regards.
 
If the client always buys AND sells at the same bank, you only need 1 bank
ID in the client table, if it can be 2 different banks, you need to have 2
separate queries. One query joined on IDBANKBUY and the other joined on
IDBANKSELL. Then create a 3rd query as a UNION of the first 2. It would look
something like:

SELECT Client.Name, Client.Address, Banks.Name, Banks.Address
FROM Client INNER JOIN Banks ON Client.IDBANKBUY = Banks.IDBANK
UNION SELECT Client.Name, Client.Address, Banks.Name, Banks.Address
FROM Client INNER JOIN Banks ON Client.IDBANKSELL = Banks.IDBANK

--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access
 
Back
Top