Results 1 to 6 of 6

Thread: about self join table

  1. #1
    Join Date
    Jul 2003
    Posts
    421

    about self join table

    I am not sure when we should use self join table any advise??
    ________
    Chevrolet Ssr
    Last edited by sql; 03-06-2011 at 02:14 AM.

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    It is usually used if you have hierarchical information in the table, for example Employee table may have a column called ManagerID with employeeID of the manager. Since a manager is also an employee, to link an employee to his/her manager, you will need to join employee table with itself.

  3. #3
    Join Date
    Jul 2003
    Posts
    421
    I know this part , but it looks like self join can use in more complicat situation , I know I did not understall it , but can't clear teld where I don't understand , proble, some good tutorial or example will help more! for example how the table1.id =table2.id+1 work in self join
    ________
    BUY PORTABLE VAPORIZERS
    Last edited by sql; 03-06-2011 at 02:14 AM.

  4. #4
    Join Date
    Jun 2004
    Location
    Atlanta and Manhattan
    Posts
    607

    Could you restate the question?

    The followup question is a bit garbled ... could you restate it so we can try to help further?

    Thanks.

    Bill

  5. #5
    Join Date
    Jul 2003
    Posts
    421
    Quote Originally Posted by Island1 View Post
    The followup question is a bit garbled ... could you restate it so we can try to help further?

    Thanks.

    Bill
    Create table PaymentRecords(
    PaymentId int Not null auto_increment ,
    UserId int Not null,
    FeeType varchar(70) default null,
    DueDate varchar(10) default null,
    SPlitPaymented varchar(35) default null,
    officerReason VARCHAR(35) default null,
    officerReasonM VARCHAR(500) default null,
    CompleteDate VARCHAR(10) default null,
    ApprovalDate VARCHAR(10) default null,
    ProcessStatus varchar(45) default null,
    PayDate varchar(50) default null,
    PRIMARY KEY (PaymentId),
    FOREIGN Key(UserId) REFERENCES Student(UserId) on Delete
    Cascade on update cascade)Type=InnoDB DEFAULT CHARSET=utf8;
    for this example can I use the self join to get all the rows with same UserId, and ProcessStatus?
    thank you
    ________
    Star craft replays
    Last edited by sql; 03-06-2011 at 02:15 AM.

  6. #6
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    You can ORDER BY UserId, and ProcessStatus to list the records together.

Posting Permissions

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