USE INFORMATION_SCHEMA;
SELECT TABLE_NAME,
COLUMN_NAME,
CONSTRAINT_NAME,
REFERENCED_TABLE_NAME,
REFERENCED_COLUMN_NAME
FROM KEY_COLUMN_USAGE
WHERE TABLE_SCHEMA = "{dbname}"
AND TABLE_NAME = "{table}"
then this is the result helper
USE INFORMATION_SCHEMA;
SELECT TABLE_NAME,
COLUMN_NAME,
CONSTRAINT_NAME,
REFERENCED_TABLE_NAME,
REFERENCED_COLUMN_NAME
FROM KEY_COLUMN_USAGE
WHERE TABLE_SCHEMA = "CONNECTION_NAME"
AND TABLE_NAME = "table_name"
note that {dbname} is replaced with "CONNECTION_NAME" instead of "db-name"
I had this connection url in my .env file
DB_UI_CONNECTION_NAME=mysql://user:pass@localhost:3306/db-name
and this table helper
then this is the result helper
note that
{dbname}
is replaced with "CONNECTION_NAME" instead of "db-name"Tested on: