0

We are trying to get result as single row from one to many relation, there are atleast 25000 rows in actor table and atleast 10 images for each,

**Table** ActorTable
ActorId Int
ActorName nvarchar
ActorAge Int

 ----------------------------------------------------------------
 ActorId    ActorName   ActorAge
 ----------------------------------------------------------------
 1          Actor1      34  
 2          Actor2      40
 3          Actor3      25
 4          Actor4      19
 5          Actor5      45
 ----------------------------------------------------------------

**Table** ActorImagesTable
ImgId Int
ActorId Int
ActorImage nvarchar

 ----------------------------------------------------------------
 ImgId      ActorId   ActorImage
 ----------------------------------------------------------------
 1          1         a.jpg
 2          1         b.jpg
 3          2         c.jpg
 4          2         d.jpg
 5          1         e.jpg
 ----------------------------------------------------------------

Want to return ActorId,ActorName, ActorAge, ActorImage

 ----------------------------------------------------------------
 ActorId    ActorName   ActorAge  ActorImage
 ----------------------------------------------------------------
 1          Actor1      34        a.jpg,b.jpg,e.jpg  
 2          Actor2      40        c.jpg,d.jpg  
 3          Actor3      25
 4          Actor4      19
 5          Actor5      45
 ----------------------------------------------------------------

Please help

Regards

Moksha
  • 1,030
  • 6
  • 17
  • 38

2 Answers2

0

n condition if you specify imageid then you will get one record .If you are simply joining using only join condition then you will get more than one record for sure because it is one to many

If you want to change rows to columns i suggest you to use Pivot

Nadendla
  • 712
  • 2
  • 7
  • 17
0

Ah, there is no GROUP_CONCAT function in SQL Server. You have to use XML PATH workaround. See Concatenate many rows into a single text string?

Community
  • 1
  • 1
Andrei Shakh
  • 181
  • 4