Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

sql

oracle

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.

like image 380
Halfwarr Avatar asked Dec 07 '22 09:12

Halfwarr


1 Answers

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

like image 167
paul Avatar answered Dec 14 '22 22:12

paul