i have three tables
1- room_info with four fields
field_name data_type description
---------- ---------- -----------
r_id number primary key
r_number number
r_floor text
1- student_info with five fields
field_name data_type description
---------- ---------- -----------
s_id number primary key
s_name text
s_college text
s_dept text
r_id number foreign key
3- como_info with five fields
field_name data_type description
---------- ---------- -----------
c_id number primary key
c_sys number
c_dosh number
c_dol number
r_id number foreign key
r_id from room_info is foreign key for both como_info and student_info
i want to make select query to select s_name,s_college,c_sys,c_dosh???
i use c# and access 2010
Loading


Sanjeeb LenkaRank #301 · 8.3K reputationPosted Aug 2, 2013, 7:23 AM EDT
Select student_info.s_name,student_info.s_college,como_info.c_sys,como_info.c_dosh
from (student_info
inner join como_info on como_info.r_id=student_info.r_id)
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 2, 2013, 8:23 AM EDT
Try like this
Regards,
Iftikar
honar abubakr62 reputationPosted Aug 2, 2013, 10:25 AM EDT
SUNIL GUTTARank #1,832 · 810 reputationPosted Aug 4, 2013, 7:06 AM EDT
como_info.r_id=student_info.r_id how could we relate tables using 2 foreign keys mate ?? made be one of this is a primary key [r_id] ???
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 4, 2013, 7:22 AM EDT
Regards,
Iftikar
SUNIL GUTTARank #1,832 · 810 reputationPosted Aug 4, 2013, 9:38 AM EDT
Well same doubt for me in-case of ur query also i.e in ur second INNERJOIN u created a relation between 2 foreign keys :) which is not in practice ..
I finally hope the above question may be wrongly mentioned so i got this little confusion
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 4, 2013, 9:59 PM EDT
Regards,
Iftikar
SUNIL GUTTARank #1,832 · 810 reputationPosted Aug 4, 2013, 10:54 PM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 4, 2013, 10:59 PM EDT
room_info is parent table where r_id is PK and
student_info and como_info are child table with relation of r_id as FK
Regards,
Iftikar
SUNIL GUTTARank #1,832 · 810 reputationPosted Aug 4, 2013, 11:01 PM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 4, 2013, 11:04 PM EDT
Regards,
Iftikar
SUNIL GUTTARank #1,832 · 810 reputationPosted Aug 4, 2013, 11:26 PM EDT