Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save alexandreelise/d55b73950992803701faf249efa14c86 to your computer and use it in GitHub Desktop.

Select an option

Save alexandreelise/d55b73950992803701faf249efa14c86 to your computer and use it in GitHub Desktop.
Detect tables which has hits feature in Joomla core
/**
* Use the information table of MySQL to fetch corresponding column name
*/
SELECT CONCAT(a.TABLE_SCHEMA,'.',a.TABLE_NAME,'.',a.COLUMN_NAME) AS c
FROM information_schema.COLUMNS AS a
WHERE a.COLUMN_NAME = 'hits';
/**
* Based on previous query, we can improve it to generate actual useful queries to execute later
*/
SELECT CONCAT('UPDATE ', a.TABLE_SCHEMA,'.',a.TABLE_NAME,' AS b ','SET b.',a.COLUMN_NAME, '=0 WHERE true;') AS c
FROM information_schema.COLUMNS AS a
WHERE a.COLUMN_NAME = 'hits';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment