Halfwarr
Halfwarr

Reputation: 8103

Sql adding a string and number and displaying it as a single column

I am trying to take a column that stores a id # for a webpage on a site and store it with the full url.

If the Article ID is 5. I want it to store return something like this

<a href="http://website.com/5">5</a>

What I am trying to do is combine a string put in the search and a number to make a URL for the column. I know this syntax is incorrect but I can not find anyway on how to do it.

SELECT
CASE                                                                        
WHEN m_tableFoo.articleId = '0' THEN                                
    'Not Applicable'                                                    
ELSE '<a href="http://website.com/'+m_tableFoo.articleId+'/">'+m_tableFoo.articleId+'</a>' 
END AS articleID
from m_tableFoo

I have tried searching the web and Stack Overflow, but I am not sure if my search wording is incorrect or my description.

Upvotes: 7

Views: 15875

Answers (1)

paul
paul

Reputation: 22001

oracle uses || for concatenation, not +. You will probably also need to TO_CHAR the article ids

Upvotes: 18

Related Questions