Giải pháp
Truy vấn hệ thống view information_schema.columns để lọc tên bảng chứa cột có tên khớp với mẫu tìm kiếm.
Cú pháp
select distinct table_name from information_schema.columns where column_name like '%yourSearchValue%' and table_schema = database();
Ví dụ: Tìm bảng có cột chứa từ "Client"
mysql> select distinct table_name
from information_schema.columns
where column_name like '%Client%'
and table_schema = database();
Kết quả mẫu:
+----------------+ | table_name | +----------------+ | demotable449 | | demotable450 | | demotable461 | | demotable517 | | demotable529 | | demotable534 | | demotable537 | | demotable543 | | demotable547 | +----------------+ 9 rows in set (1.19 sec)
Kiểm tra cấu trúc một bảng
Dùng DESCRIBE hoặc SHOW COLUMNS để xem chi tiết cột.
Lưu ý: Thay database() bằng tên database cụ thể nếu cần.