Trying to create emails for staff using substr()

Viewed 14

Trying to combine a first name, a last name, and then concatenate with a email address ending. ie fname = John, lname = Smith, email portion is @PROP.com in OracleSQL developer

SELECT SUBSTR(CONCAT(fname, lname),0,LENGTH(FNAME+1)) FROM STAFF;

1 Answers

You may use:

SELECT fname, lname, fname || SUBSTR(lname, 1, 1) || '@PROP.com' AS email
FROM STAFF;

I suggest using || for multiple concatenations here as the CONCAT() function only accepts two parameters.

Related