0brine
0brine

Reputation: 486

SQL : combine 2 rows into 1

This is my database

|
|
|

I'm trying to display "hello" and "wo" in the same column

My SQL statement:

SELECT 
    d.CampaignId, d.ClientID, 
    citn.ImagePath AS Thumbnail, cidi.ImagePath AS DetailImage
FROM  
    MasterData.CampaignImage AS d 
INNER JOIN
    MasterData.CampaignImage AS citn ON d.CampaignId = citn.CampaignId  
                                     AND d.ClientID = citn.ClientID 
                                     AND citn.ImageTypeId = 1 
INNER JOIN
    MasterData.CampaignImage AS cidi ON d.CampaignId = cidi.CampaignId 
                                     AND d.ClientID = cidi.ClientID 
                                     AND cidi.ImageTypeId = 2

The output:

enter image description here

But now I have 2 rows in my output, how can I combine these into just one row?

Upvotes: 0

Views: 70

Answers (1)

jarlh
jarlh

Reputation: 44696

Simply do SELECT DISTINCT to skip duplicate rows.

Upvotes: 3

Related Questions