Results 1 to 2 of 2

Thread: (Resolved) How to retrieve record from 3 tables by comparing the foreign key?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2003
    Posts
    68

    Question (Resolved) How to retrieve record from 3 tables by comparing the foreign key?

    Hi, I got problem retrieveing data from 3 tables using e foreign key which is the unique identifier.

    I am using the staffNo as the unique identifier.If i search e staff record, it should show the staff table and if the loan or zip got his record, then will display all the record out n display in a datagrid.
    If he never borrow anything, then there wont be any record in loan n zip, so it will only display the staff record.

    How do i acheive it? How do i write the sql statement?
    Last edited by berrie_luv; Oct 15th, 2003 at 04:45 AM.

  2. #2
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Try something like this:

    SELECT * FROM Staff
    JOIN Loan ON StaffNo = StaffNo
    JOIN Zip ON staffNo = StaffNo

Posting Permissions

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



Click Here to Expand Forum to Full Width