SELECT TOP ( @PageSize )
ISNULL(c.CName + '('
+ ( STUFF(( SELECT ',' + LTRIM(RTRIM(TureName))
FROM dbo.User r
INNER JOIN dbo.ClassOfTeacher ct ON ct.CID = c.id
AND ct.TeacherID = r.id
FOR
XML PATH('')
), 1, 1, '') ) + ')', c.CName) AS TrueName ,
c.ID ,
c.TID ,
c.CName
FROM dbo.Class c
WHERE TID = @TID
ORDER BY c.CName
ISNULL(c.CName + '('
+ ( STUFF(( SELECT ',' + LTRIM(RTRIM(TureName))
FROM dbo.User r
INNER JOIN dbo.ClassOfTeacher ct ON ct.CID = c.id
AND ct.TeacherID = r.id
FOR
XML PATH('')
), 1, 1, '') ) + ')', c.CName) AS TrueName ,
c.ID ,
c.TID ,
c.CName
FROM dbo.Class c
WHERE TID = @TID
ORDER BY c.CName