Skip to content

Instantly share code, notes, and snippets.

@cbrhex
Created September 14, 2016 08:38
Show Gist options
  • Save cbrhex/2db89efd287490bd41ca54bbe2430015 to your computer and use it in GitHub Desktop.
Save cbrhex/2db89efd287490bd41ca54bbe2430015 to your computer and use it in GitHub Desktop.
CREATE DEFINER=`root`@`root` PROCEDURE `procedure_name`()
BEGIN
IF (SELECT count(*)
FROM information_schema.TABLES
WHERE
TABLE_SCHEMA = 'DB_NAME' -- Database name
AND TABLE_NAME = 'TABLE_NAME' AND ...) = 0 THEN
SELECT ...; -- not exists
ELSE
SELECT ...; -- exists
END IF;
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment