如何在MySQL中显示某些列(不是全部)?
为了显示某些列,请使用NOTIN并设置您不想显示的那些列。让我们首先创建一个表。以下是查询-
mysql> create table student_Information -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentName varchar(50), -> StudentAge int, -> StudentAddress varchar(100), -> StudentAllSubjectScore int -> );
以下是查询以显示有关上表的描述-
mysql> desc student_Information;
这将产生以下输出-
+------------------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------------------+--------------+------+-----+---------+----------------+ | StudentId | int(11) | NO | PRI | NULL | auto_increment | | StudentName | varchar(50) | YES | | NULL | | | StudentAge | int(11) | YES | | NULL | | | StudentAddress | varchar(100) | YES | | NULL | | | StudentAllSubjectScore | int(11) | YES | | NULL | | +------------------------+--------------+------+-----+---------+----------------+ 5 rows in set (0.00 sec)
以下是仅显示一些列的查询-
mysql> SHOW COLUMNS FROM student_Information where field not
in('StudentAddress','StudentAllSubjectScore');这将产生以下输出-
+-------------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+-------------+------+-----+---------+----------------+ | StudentId | int(11) | NO | PRI | NULL | auto_increment | | StudentName | varchar(50) | YES | | NULL | | | StudentAge | int(11) | YES | | NULL | | +-------------+-------------+------+-----+---------+----------------+ 3 rows in set (0.00 sec)
热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短