-
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.
-
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.
-
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.
-
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
-
Originally Posted by Island1
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.
-
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
-
Forum Rules
|
|