CONCAT

SQL -> Funkcie -> Funkcie pre prácu s reťazcami -> CONCAT

Syntax

CONCAT(str1,str2,...)

Popis

Príkaz jazyka SQL
Returns the string that results from concatenating the arguments. May have one or more arguments. If all arguments are non-binary strings, the result is a non-binary string. If the arguments include any binary strings, the result is a binary string. A numeric argument is converted to its equivalent binary string form; if you want to avoid that, you can use an explicit type cast, as in this example:
SELECT CONCAT(CAST(int_col AS CHAR), char_col) FROM dual;

CONCAT() returns NULL if any argument is NULL.

Príklad

SELECT CONCAT('My', 'S', 'QL') FROM dual;
        -> 'MySQL'
SELECT CONCAT('My', NULL, 'QL') FROM dual;
        -> NULL
SELECT CONCAT(14.3) FROM dual;
        -> '14.3'


Rozdiel medzi databázami

Na niektorých databázach sa dá použiť spájanie reťazcov jednoduchšie pomocou operátora ||

Pozri aj

CONCAT_WS