Advanced Search

Results 1 to 4 of 4

Thread: Display value using a Foreign Key

  1. #1
    Join Date
    Jun 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Display value using a Foreign Key

    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

  2. #2
    Join Date
    Jul 2006
    Posts
    497
    Thanks
    8
    Thanked 70 Times in 70 Posts

    Default

    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.
    -- Chris
    informal JavaScript student of Douglas Crockford
    I like wikis - a lot.

  3. #3
    Join Date
    May 2009
    Posts
    62
    Thanks
    19
    Thanked 3 Times in 3 Posts

    Default

    Where's the foreign key there?

  4. #4
    Join Date
    May 2009
    Posts
    62
    Thanks
    19
    Thanked 3 Times in 3 Posts

    Default

    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.....

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •