为此,您可以使用SHOW COLUMNS命令。以下是语法。在这里,我们使用LIKE设置了字符串-
SHOW COLUMNS FROM yourTableName LIKE ‘yourStringValue’;
让我们首先创建一个表-
mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> FirstName varchar(20), -> LastName varchar(20) -> );
这是查询以选择包含特定字符串的列名称-
mysql> SHOW COLUMNS FROM DemoTable LIKE 'FirstName';
输出结果
+-----------+-------------+------+-----+----------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------+-------------+------+-----+----------+-------+ | FirstName | varchar(20) | YES | | NULL | | +-----------+-------------+------+-----+---------+-------+ 1 row in set (0.05 sec)