Return a computed value from SQL code.
Section: stored procedures and functions
Create a scalar function
sql
sql
DELIMITER $$
CREATE FUNCTION full_label(p_first VARCHAR(100), p_last VARCHAR(100))
RETURNS VARCHAR(255)
DETERMINISTIC
BEGIN
RETURN CONCAT(p_first, ' ', p_last);
END $$
DELIMITER ;Explanation
Stored functions can be used inside SELECTs and other expressions.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing stored procedures and functions