Click here to Skip to main content
15,888,803 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi to all!

here i find difficult to write a querry

can u help me to write that querry

i have three tables T1, T2, T3

T1 has fields
u/id and mrf/id

T2 has fields
mrf/id and m/id

T3 has fields
m/id and m/name


given i have u/id and i have to get m/name
Posted
Updated 8-Aug-11 23:02pm
v2

SQL
select mid
from T3
inner join T2 on T3.mid = T2.mid
inner join T1 on T1.mrfid = T2.mrfid and T1.uid = @uid
 
Share this answer
 
Comments
kami124 9-Aug-11 6:13am    
ok i make it like this
but the result is displaying name of field
but i need the values of field
i make my code like this



select modname_vc
from sec_modules
inner join sec_mrf_details on sec_modules.modid_int=sec_mrf_details.modid_int
inner join sec_umrf_details on sec_mrf_details.mrfno_nu=sec_umrf_details.mrfno_nu
where sec_umrf_details.userid_vc='ali'
Here it is
select mname from T3 where mid in(select mid from T2 where mrfid in(select mrfid from T1 where uid=@uid))
 
Share this answer
 
Comments
kami124 9-Aug-11 5:33am    
ya its showing only the field name
i want field values
_Zorro_ 9-Aug-11 5:40am    
Hi, you should take a look at Abhinav S query, it's way more performant than using SELECT IN, if you don't believe me take a look at your execution plan, the difference should be obvious.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900