MySQL 如何显示一些列(不是全部列)

MySQL 如何显示一些列(不是全部列)

为了显示一些列,请使用 NOT IN 并设置不想显示的那些列。 让我们首先创建一个表。 以下是查询 –

mysql > create table student_Information
   ->(
   -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   -> StudentName varchar(50),
   -> StudentAge int,
   -> StudentAddress varchar(100),
   -> StudentAllSubjectScore int
   ->);
Query OK, 0 rows affected(0.69 sec)

以下是用于显示上述表的描述的查询 –

mysql> desc student_Information;

这将产生以下输出 –

+ ------------------------ + -------------- + ------ + ----- + -------- + ---------------- +
| 字段 | 类型 | 空 | 键 | 默认值 | 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行在集合中(0.00 sec)

以下是仅显示一些列的查询 –

mysql> SHOW COLUMNS FROM student_Information where field not
in('StudentAddress','StudentAllSubjectScore');

这将产生以下输出 –

+ ------------- + ------------- + ------ + ----- + -------- + ---------------- +
| 字段 | 类型 | 空 | 键 | 默认值 | Extra |
+ ------------- + ------------- + ------ + ----- + -------- + ---------------- +
| StudentId | int(11)| NO | PRI | NULL | auto_increment |
| StudentName | varchar(50)| YES | | NULL | |
| StudentAge | int(11)| YES | | NULL | |
+ ------------- + ------------- + ------ + ----- + -------- + ---------------- +
3行在集合中(0.00 sec)

阅读更多:MySQL 教程

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程