Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 problem with fetching data

Author  Topic 

veerapureddy
Starting Member

4 Posts

Posted - 2008-03-04 : 07:23:06
Hi i have 6 tables

1.location
id primary key
authorization string
count int
2.account
acc_id primary key
loc_id foreign key of location table
hsr string
3.Line
id primary key
intaralata string
interalat string
4.trunk
id primary key
intaralata string
interalat string
5.RCF
id primary key
intaralata string
interalat string
6.TSG
id primary key
intaralata string
interalat string

now i need to fetch the field authorization from location table by the following conditins

LOCATION.AUTHORIZATION using ACCOUNT.LOC_ID. If any (LINE/TRUNK/TSG/RCF.INTERLATA/INTRALATA= ’F’), and this value is blank, send LOCATION.AUTHORIZATION

can anyone help me out in this scenario. i need the sql query for fetching that fiels.

thanks in advanvce




harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-03-04 : 07:33:39
Not quite sure what you mean.

Something like this?

Select l.authorization 
from location l JOIN account a on a.loc_id = l.id
where exists
(
select * from Line where INTRALATA= 'F'
union all
select * from trunkwhere INTRALATA= 'F'
union all
...
)


Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

veerapureddy
Starting Member

4 Posts

Posted - 2008-03-05 : 00:56:38
Hi Harsh thanks for ur reply and sorry for not explaining my problem clearly.

again im explaining the problem, please provide me the query.

i am having the follong tables

1)location table contains one PK(loc_id)and authorization field, etc.
2)accont table contain one FK(loc_id) and hrid , attuid fields etc

3)LINE table contains INTERLATA_PIC_FREEZE & INTRALATA_PIC_FREEZE and some more fields.
4)TRUNK table contains INTERLATA_PIC_FREEZE & INTRALATA_PIC_FREEZE and some more fields.
5)NODAL_TSG table contains INTERLATA_PIC_FREEZE & INTRALATA_PIC_FREEZE and some more fields.
6)REMOTE_CALL_FWD table contains INTERLATA_PIC_FREEZE & INTRALATA_PIC_FREEZE and some more fields.

7)Order2misc table contains FK(SER_LOC_ID) of Location table

PIC means INTERLATA_PIC_FREEZE/INTRALATA_PIC_FREEZE
PLOC means INTERLATA_PIC_FREEZE/INTRALATA_PIC_FREEZE

i need to send an authorization field value to another interface.

condition
===========
if(LOCATION.AUTHORIZATION using Account.loc_id is not null and LINE.INTERLATA_PIC_FREEZE not equal to 'F' and LINE.INTRALATA_PIC_FREEZE not equal to 'F' and similaraly for TRUNK, NODAL_TSG and REMOTE_CALL_FWD table fields)
else
(
fetch the authorization field from
LOCATION.AUTHORIZATION using Order2misc.ser_loc_id

)
Go to Top of Page

veerapureddy
Starting Member

4 Posts

Posted - 2008-03-05 : 00:57:06
Hi Harsh thanks for ur reply and sorry for not explaining my problem clearly.

again im explaining the problem, please provide me the query.

i am having the follong tables

1)location table contains one PK(loc_id)and authorization field, etc.
2)accont table contain one FK(loc_id) and hrid , attuid fields etc

3)LINE table contains INTERLATA_PIC_FREEZE & INTRALATA_PIC_FREEZE and some more fields.
4)TRUNK table contains INTERLATA_PIC_FREEZE & INTRALATA_PIC_FREEZE and some more fields.
5)NODAL_TSG table contains INTERLATA_PIC_FREEZE & INTRALATA_PIC_FREEZE and some more fields.
6)REMOTE_CALL_FWD table contains INTERLATA_PIC_FREEZE & INTRALATA_PIC_FREEZE and some more fields.

7)Order2misc table contains FK(SER_LOC_ID) of Location table

PIC means INTERLATA_PIC_FREEZE/INTRALATA_PIC_FREEZE
PLOC means INTERLATA_PIC_FREEZE/INTRALATA_PIC_FREEZE

i need to send an authorization field value to another interface.

condition
===========
if(LOCATION.AUTHORIZATION using Account.loc_id is not null and LINE.INTERLATA_PIC_FREEZE not equal to 'F' and LINE.INTRALATA_PIC_FREEZE not equal to 'F' and similaraly for TRUNK, NODAL_TSG and REMOTE_CALL_FWD table fields)
else
(
fetch the authorization field from
LOCATION.AUTHORIZATION using Order2misc.ser_loc_id

)
Go to Top of Page
   

- Advertisement -