How to Loop the unmatched rows data from two tables in sqlserver 2012

  • Hi All,

    I need solution on below issue which became painful in my current project ,

    Please suggest me on below issue

    Issue: we are having folder table and team table as like below structure.

    Folderlist (F)Table: (

    ==============

    id ,folder_name, parent_id

    1, c, 101

    2,b,202

    3,c,203

    Teamlist table (T)

    ============

    team_id, Team_name, Parent_folderid

    101 , mobile,101

    202 ,Tab,200

    200, Phone,200

    203,apple,205

    205,nokia,208

    208,samsung,208

    If F.parent_id(101)=T.team_id(101) and T.team_id(101)=T.parent_folder_id (101)

    then output should come as 'Mobile/c' (this is for f.parent_id=101)

    If F.Parent_id=T.team_id and T.team_id!=T.parent_folder_id

    then parent_folder_id have to start search on team_id column where it got match and pick the Team_name from that corresponding id

    Ex: F.parent_id=202 is matching with T.Team_id (202) but this T.team_id(202) is not matching with T.parent_folderid(200) , so this T.parent_folderid (200) have to search on T.id (200) ,if now T.id(200) is matching with T.Parent_folder_id(200) then it have to give the names from the starting hirache

    like phone/tab/b (this is for F.parent_id=202)

    Kindly help me on this.

    Regards,

    Saikumar K.

  • Please do not crosspost. It wastes peoples time and fragments replies.

    Original thread can be found here:

    http://www.sqlservercentral.com/Forums/Topic1650619-391-1.aspx

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply