Sunday January 21st 2018

Categories

Insider

Archives

Examples Use string concatenation

Recently I was trying to import datafeeds into the wordpress blog. images on the post and links needs some html tags. I used SQL language string concatenation operator to fill up the missing tags as follows;

select  [name], ‘<img src=”‘ + ” +IMAGEURL + ‘”‘ + ‘ Detail: ‘ + [description]+ ‘, ‘+ ‘Price in USD:’+ ‘, ‘+ cast(PRICE as CHAR)+ ‘, ‘+ ‘<a href=”‘ + ” +BUYURL +  ‘”>[Read More and Booking information] </a>’

,  KEYWORDS from

 dbo.[‘Hotels_com-International_Hotels$’]

 where KEYWORDS like ‘%doha%’ or

 KEYWORDS like ‘%Manama%’ or

 KEYWORDS like ‘%Mumbai%’ or

 KEYWORDS like ‘%Tokyo%’ or

 KEYWORDS like ‘%Dubai%’ or

 KEYWORDS like ‘%Dallas%’ or

 KEYWORDS like ‘%Houston%’ or

 KEYWORDS like ‘%Chicago%’ or

 KEYWORDS like ‘%NYC%’  or

 KEYWORDS like ‘%toronto%’