Tuesday, January 15, 2013

Combine STRING on ORACLE


We could append String on ORACLE by ‘||’.
Examples Statement:
SELECT ‘Vietnam’ || ‘ ‘ || ‘ is beautiful’ AS “My country” FROM DUAL;


Examples Statement:
SELECT FIRST_NAME || ‘ ‘ || LAST_NAME AS “NAME” FROM EMPLOYEES;


We could use CONCAT(String1, String2) to append String. CONCAT function has two parameter, so when you want to combine more than 2 String, we need to use nest statements. For statements above, we could write them again:
SELECT CONCAT(‘Vietnam’, CONCAT(‘ ’, ‘is beautiful’))  FROM DUAL;
SELECT CONCAT(FIRST_NAME, CONCAT(‘ ’, LAST_NAME))  AS “NAME” FROM EMPLOYEES;

No comments:

Post a Comment