开发者

How to concat datatypes like integers(integer with integer) & varchar(varchar with varchar) in mysql?

开发者 https://www.devze.com 2022-12-24 01:26 出处:网络
How can 开发者_JS百科we concat integers with integers varchar with varchar int with varchar in MySQL ?Use CONCAT

How can 开发者_JS百科we concat

  1. integers with integers
  2. varchar with varchar
  3. int with varchar

in MySQL ?


Use CONCAT

http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_concat

SELECT CONCAT(1, 2);
-- "12"

SELECT CONCAT('foo', 'bar');
-- "foobar"

SELECT CONCAT(1, 'bar');
-- "1bar"


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);

5.1 Documentations


For two columns concatenation name: CHAR and no: int

PIG syntax is CONCAT(name,(CHARARRAY)no);

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号