Skip to content

Instantly share code, notes, and snippets.

@arisnew
Created August 13, 2025 02:28
Show Gist options
  • Select an option

  • Save arisnew/ce58e38d61e4892dfeba37292d77feb8 to your computer and use it in GitHub Desktop.

Select an option

Save arisnew/ce58e38d61e4892dfeba37292d77feb8 to your computer and use it in GitHub Desktop.
Check column relation to another table MYSQL
SELECT
    TABLE_NAME,
    COLUMN_NAME,
    CONSTRAINT_NAME,
    REFERENCED_TABLE_NAME,
    REFERENCED_COLUMN_NAME
FROM
    INFORMATION_SCHEMA.KEY_COLUMN_USAGE
WHERE
    REFERENCED_TABLE_SCHEMA = 'your_database_name'
    AND REFERENCED_TABLE_NAME = 'your_table_name'
    AND REFERENCED_COLUMN_NAME = 'your_column_name';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment