tags:

views:

170

answers:

1

How can we concat

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

in MySQL ?

+1  A: 

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"
nickf
It is used for integers as well as for varchars ? because I was under the impression that CONCAT is used only for string types.
Rachel
Yes, it converts the integers. You can find the details if you follow the link @nickf provided.
titanoboa