Log in

View Full Version : Display value using a Foreign Key



ignitedintelligence
06-22-2009, 11:35 AM
Hi guys,

Can anyone please help me with this? I have two tables register and marks. Reg no is the primary key for Register table and P_int is the primary key for marks. Now i want to display marks for the person with the reg no 111.. how to do it?

Note: The fields in marks are P_int, subj1, subj2, subj3.. and fields in register are reg no, name, username and password..

Thanks in advance..

Regards,
ii

Jesdisciple
06-22-2009, 08:38 PM
Add a field to the Register table which contains the corresponding P_int. When you look up the user, you get the index for the marks table and can look up the user's marks.

heavensgate15
06-23-2009, 05:04 AM
Where's the foreign key there?

heavensgate15
06-23-2009, 05:56 AM
You can add P_int as foreign key in register table... Then you can access the mark table and display its contents through the register table:

select mark.* from register,mark where reg_no = 110 and register.P_int = mark.P_int;


This is not tested yet, but you can try it out hahaahhahha... This will select the row in mark table having reg_no = 110 in the register table.....