Skip to content

Instantly share code, notes, and snippets.

@maulvi
Created September 18, 2017 02:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maulvi/1c4fcb9e17b5f26db0784665b96799db to your computer and use it in GitHub Desktop.
Save maulvi/1c4fcb9e17b5f26db0784665b96799db to your computer and use it in GitHub Desktop.
trigger
BEGIN
DECLARE
email_count INT;
SELECT COUNT(*)
INTO email_count
FROM employees
WHERE LCASE()
IF email_count > 0
THEN
SET NEW.email = CONCAT_WS(NEW.lastName, LEFT(NEW.firstName, 1), email_count, '@classicmodelcars.com');
ELSE
SET NEW.email = CONCAT_WS(NEW.lastName, LEFT(NEW.firstName, 1), '@classicmodelcars.com');
END IF;
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment