Click here to Skip to main content
15,906,081 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have two tables t1 and t2

t1 has three fields
f1, f2, f3 where f1 is primary key

and t2 has three fields
f1, fb, fc where f1 is foreign key



now from f1 and fb i want to get f3

how i have to do
Posted
Updated 27-Jul-11 23:34pm
v2

SQL
SELECT t2.f3 FROM t2
INNER JOIN t1 ON t1.f1 = t2.f1
WHERE t1.fb = 'value'


Read more about JOINS[^].
 
Share this answer
 
From what I understood from you (incomplete, unclear) question:

SQL
SELECT
    T2.F3
FROM T1 INNER JOIN T2 ON
    T1.F1 = T2.f1
WHERE
    T1.F1 = 'whatever'
    AND T2.Fb = 'I do not care'
 
Share this answer
 
Comments
kami124 28-Jul-11 6:27am    
but the value is not displaying only the name of field is displayed

select sec_mrf_details.fnid_int
from sec_umrf_details
inner join
sec_mrf_details
on
sec_umrf_details.mrfno_nu = sec_mrf_details.mrfno_nu
where
sec_umrf_details.userid_vc='abc'
and
sec_umrf_details.mrfno_nu=1
kami124 28-Jul-11 6:30am    
here in my code
sec_umfr_details is table 1 having userid_vc, mrfno_nu
sec_mrf_details is table 2 having mrfno_nu and fnid

i have userid_vc and mrfno_nu
and i have to display fnid

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