Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cross linked table ??

Status
Not open for further replies.

FluFFy05

Programmer
Jul 4, 2000
19
CA
My problem is that i have some user that have some sector more than thier office!!

Table(USER)
user_id
office_id
user_name
...

Table(OFFICE)
office_id
office_name
...

Table(SECTOR_OFFICE)
office_id
sector_id

Table(SECTOR_USER)
user_id
sector_id

By example : Office1 have sector(1001,1002,1003) but i have a user1 in Office1 who have sector (1005) and me i want to sort the sector by user1 and i want to have (1001,1002,1003,1005)
 
The first variant:
select sector_id
from sector_office where office_id in(select office_id
from office where office_name = 'office1')
union
select sector_id
from sector_user where user_id in(select user_id from
user where office_id in(select office_id from office
where office_name = 'officce1'))

the second variant without duplicates of sector_id is

select distinct t.* from
(
select sector_id
from sector_office where office_id in(select office_id
from office where office_name = 'office1')
union
select sector_id
from sector_user where user_id in(select user_id from
user where office_id in(select office_id from office
were office_name = 'officce1'))
) as t John Fill
1c.bmp


ivfmd@mail.md
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top