programing

mariadb의 문자열에 대한 SQL Content

javajsp 2023. 6. 8. 19:22

mariadb의 문자열에 대한 SQL Content

저는 XAMP에서 로컬 데이터베이스 Mariadb에서 작업하고 있으며 int에 단어를 추가/컨택하고 싶습니다. 이것은 제 질문입니다.

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

결과는 ID:3747이어야 합니다.

내가 여기서 뭘 잘못하고 있는 거지?

CONCAT를 사용합니다.
그리고.IS연산자는 [NOT] NULL에만 사용됩니다.
F.e.select col from tbl where col IS NOT NULL

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

하지만 당신은 사용할 수 있습니다.IN또한.

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

언급URL : https://stackoverflow.com/questions/70529943/sql-concat-int-to-string-in-mariadb