Home » SQL & PL/SQL » SQL & PL/SQL » linking tables
linking tables [message #11070] Thu, 04 March 2004 10:29 Go to next message
rajni
Messages: 11
Registered: July 2002
Junior Member
Hi,

I hope somebody can help me. I have 3 tables.
Table 1 = info on taxes
Table 2 = info on specific contracts
Table 3 = linking table between the two
(pk consists of tx_id and con_id)

How would I show for one type of taxes all of the contracts associated with it?
For example
Provincial taxes - Regular Contracts
Irregular Contracts etc.

Thanks,
Rajni
Re: linking tables [message #11072 is a reply to message #11070] Thu, 04 March 2004 11:29 Go to previous messageGo to next message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
select t1.tx_id, t2.contract_desc
  from t1, t2, t3
 where t1.type = 'taxtype1'   -- filter tax table
   and t3.tx_id = t1.tx_id    -- join to xref table
   and t2.con_id = t3.con_id; -- join to contracts table
Re: linking tables [message #11092 is a reply to message #11072] Fri, 05 March 2004 03:53 Go to previous message
rajni
Messages: 11
Registered: July 2002
Junior Member
Hi,

This answer works. However the problem is that when you link it this way I don't see all the contracts for a particular tac type.

For Example:
tax type contract_id
43 23
43 24
43 25

Since it is taking the linking table I see only the ones that are relevant.
1. I want to see all the types like this
43 22
23
24
25
2. And also I want to see tax type only once... if I group it together I still see all the tax types many times.... how do I overcome this?

Thanks
Rajni
Previous Topic: ^L in first line in spool file
Next Topic: Query error - ORA-01722: invalid number
Goto Forum:
  


Current Time: Thu Apr 25 00:47:34 CDT 2024