Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Concatenate String in Result

Let's say I have the following query:

SELECT anInteger FROM table;

How do I make that query concatenate a url on the front - so each row returned becomes:

'http://aurl.com/something?q=anInteger'

Note it must be the query itself that performs the concatenation - obviously in a situation where you are getting the results into a language you should concatenate in the language.

like image 873
Alex Coplan Avatar asked Dec 23 '11 02:12

Alex Coplan


1 Answers

You would use something like:

SELECT 'http://aurl.com/something?q=' + cast(anInteger as varchar) FROM table;
like image 186
paxdiablo Avatar answered Oct 06 '22 00:10

paxdiablo