Home > Mobile >  SQL Concat int to string in mariadb
SQL Concat int to string in mariadb

Time:12-31

Iam working in XAMP on a local database Mariadb and want to add/concat a word to an int This is my query

Select 'id:'   cast(Cid as varchar) from table where Cid is 3747;

The result should be id:3747

What am I doing wrong here?

CodePudding user response:

Use CONCAT.
And the IS operator is only used for [NOT] NULL.
F.e. select col from tbl where col IS NOT NULL

select concat('id:', Cid) as result
from table 
where Cid = 3747

But you could use IN also

select concat('id:', Cid) as result
from table 
where Cid in (3747) 
  • Related