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

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

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

mysql > create table student_Information
   ->(
   -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY
   -> StudentName varchar50),
   -> StudentAge int
   -> StudentAddress varchar100),
   -> StudentAllSubjectScore int
   ->);
Query OK 0 rows affected0.69 sec
Mysql

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

mysql> desc student_Information;
Mysql

这将产生以下输出 –

+ ------------------------ + -------------- + ------ + ----- + -------- + ---------------- +
| 字段 | 类型 |  |  | 默认值 | Extra |
+ ------------------------ + -------------- + ------ + ----- + -------- + ---------------- +
| StudentId | int11)| NO | PRI | NULL | auto_increment |
| StudentName | varchar50)| YES | | NULL | |
| StudentAge | int11)| YES | | NULL | |
| StudentAddress | varchar100)| YES | | NULL | |
| StudentAllSubjectScore | int11)| YES | | NULL | |
+ ------------------------ + -------------- + ------ + ----- + -------- + ---------------- +
5行在集合中(0.00 sec
Mysql

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

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

这将产生以下输出 –

+ ------------- + ------------- + ------ + ----- + -------- + ---------------- +
| 字段 | 类型 |  |  | 默认值 | Extra |
+ ------------- + ------------- + ------ + ----- + -------- + ---------------- +
| StudentId | int11)| NO | PRI | NULL | auto_increment |
| StudentName | varchar50)| YES | | NULL | |
| StudentAge | int11)| YES | | NULL | |
+ ------------- + ------------- + ------ + ----- + -------- + ---------------- +
3行在集合中(0.00 sec
Mysql

阅读更多:MySQL 教程

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程

登录

注册