Use ANSI Joins, instead of self joins, something like the below:
 SEECT M1.Name As Parent, M1.Id As ParentId, M2.[name] AS Child, M2.Id AS 
ChildID
FROM Member M1
INNER JOIN Member M2 ON M2.Id = M1.Parent
 Ryan

 On 8/10/05, krishan kant chamoli <[EMAIL PROTECTED]> wrote: 
> 
> Hi Riyaz,
> 
> In order to make tree view you have to perform self join
> 
> Say Table Name: Member
> 
> SELECT M1.Name As Parent, M1.Id As ParentId, M2.name <http://m2.name/> As 
> Child, M2.Id As ChildID
> FROM Member M1, Member M2
> WHERE M1.Id = M2.Parent]
> 
> Thanks & Regards
> 
> Krishan Kant 
> 
> Yusrizal Fahmi <[EMAIL PROTECTED]> wrote:
> Team,
> 
> 
> 
> Please help me on this following problem. for examples I have a data:
> 
> 
> 
> Id name level parent
> 
> ---------------------------------------------------------------
> 
> 1 Director 1 0
> 
> 2 Marketing 2 1
> 
> 3 Sales 2 1
> 
> 4 Marketing Staff1 3 2
> 
> 5 Marketing Staff2 3 2
> 
> 6 Sales Staff1 3 3
> 
> 7 Sales Staff2 3 3
> 
> 8 Sales Staff3 3 3
> 
> 
> 
> I want to make a sql syntax to produce result like:
> 
> 
> 
> Id name level parent
> 
> ---------------------------------------------------------------
> 
> 1 Director 1 0
> 
> 2 Marketing 2 1
> 
> 4 Marketing Staff1 3 2
> 
> 5 Marketing Staff2 3 2
> 
> 3 Sales 2 1
> 
> 6 Sales Staff1 3 3
> 
> 7 Sales Staff2 3 3
> 
> 8 Sales Staff3 3 3
> 
> 
> 
> Basically it's a tree data, but I don't have a clue how to make the 
> result.
> Please help me.
> 
> 
> 
> Thanks
> 
> rizal
> 
> 
> 
> 
> -- 
> No virus found in this outgoing message.
> Checked by AVG Anti-Virus.
> Version: 7.0.338 / Virus Database: 267.10.5/67 - Release Date: 8/9/2005
> 
> 
> 
> [Non-text portions of this message have been removed]
> 
> 
> 
> 
> 
> 
> 
> 
> Yahoo! Groups Links
> 
> 
> 
> 
> 
> 
> 
> 
> --------------------------------------------------------------------
> Krishan Kant Chamoli Office: +91-172-2653886
> Sikhya Solutions (P) Ltd., Fax: +91-172-5018485
> 24/3, Industrial Area, Phase - 2, Mobile: 9888263726
> Chandigarh. INDIA. Pin - 160002. Email: [EMAIL PROTECTED]
> 
> --------------------------------------------------------------------
> Send instant messages to your online friends http://uk.messenger.yahoo.com 
> 
> [Non-text portions of this message have been removed]
> 
> 
>  ------------------------------
> YAHOO! GROUPS LINKS 
> 
> 
>    - Visit your group 
> "AspNetAnyQuestionIsOk<http://groups.yahoo.com/group/AspNetAnyQuestionIsOk>" 
>    on the web.
>     - To unsubscribe from this group, send an email to:
>    [EMAIL PROTECTED]<[EMAIL PROTECTED]>
>     - Your use of Yahoo! Groups is subject to the Yahoo! Terms of 
>    Service <http://docs.yahoo.com/info/terms/>. 
> 
> 
>  ------------------------------
> 



-- 
Thank you,
Ryan Olshan
<asp:Web Programmer, Owner />
TeraNet Systems
http://www.teranetsystems.com


----------Internet E-Mail Confidentiality Statement----------
The content of and attachment(s) to this electronic transmission are 
intended for the use of the person, firm or entity to which it is directed, 
and may contain information that is private, confidential, exempt from 
disclosure under applicable law, and/or proprietary to TeraNet Systems. If 
you are not the intended recipient, or the employee or agent responsible for 
delivering this message to the intended recipient, any dissemination, 
distribution or copying of this communication is strictly prohibited. If you 
have received this message in error, please kindly destroy it and notify the 
sender, [EMAIL PROTECTED], immediately by reply e-mail. Thank you for 
your cooperation. 
-------------------------------------------------------------------------------


[Non-text portions of this message have been removed]



------------------------ Yahoo! Groups Sponsor --------------------~--> 
<font face=arial size=-1><a 
href="http://us.ard.yahoo.com/SIG=12hsheldn/M=362329.6886308.7839368.1510227/D=groups/S=1705006764:TM/Y=YAHOO/EXP=1123742347/A=2894321/R=0/SIG=11dvsfulr/*http://youthnoise.com/page.php?page_id=1992
">Fair play? Video games influencing politics. Click and talk back!</a>.</font>
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to