SQL Concatenate String as a Result

Let's say I have the following query:

SELECT anInteger FROM table; 

How to make this request a concatenation of the front-panel URL, so each returned line becomes:

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

Note that this must be the query itself that performs the concatenation - obviously in a situation where you get results in a language that you must concatenate in a language.

+6
source share
2 answers

You would use something like:

 SELECT 'http://aurl.com/something?q=' + cast(anInteger as varchar) FROM table; 
+7
source

it will depend on the DBMS used:

MySQL:

SELECT concat (anInteger, "your line goes here") FROM table;

PostgreSQL:

SELECT anInteger || "your line goes here";

Oracle:

Same as PostgreSQL

+2
source

Source: https://habr.com/ru/post/904361/


All Articles