Skip to content

Instantly share code, notes, and snippets.

@MagePsycho
Last active August 7, 2017 18:52
Show Gist options
  • Save MagePsycho/5f56fa0a4ffeba9109510e27520cf80c to your computer and use it in GitHub Desktop.
Save MagePsycho/5f56fa0a4ffeba9109510e27520cf80c to your computer and use it in GitHub Desktop.
MySQL: Dynamic Table + SQL
-- @author Raj KB
-- @website http://blog.magepsycho.com
SET @STORE_ID = 7;
SET @CATALOG_FLAT_TABLE = CONCAT('catalog_product_flat_', @STORE_ID);
SET @QUERY = CONCAT('SELECT * FROM ', @CATALOG_FLAT_TABLE, ' LIMIT 10');
PREPARE stmt FROM @QUERY;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment