Created
September 18, 2017 02:02
-
-
Save maulvi/1c4fcb9e17b5f26db0784665b96799db to your computer and use it in GitHub Desktop.
trigger
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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