1.别名
给查询的字段改个名字,只对查询结果有影响,对表结构以及数据不会产生任何影响
先创建一张表并添加数据
CREATE DATABASE mahaiwuji;
USE mahaiwuji;
CREATE TABLE student (
sid INT PRIMARY KEY AUTO_INCREMENT,
sname VARCHAR (32),
sage INT
) ENGINE = INNODB DEFAULT CHARSET = utf8;
INSERT INTO student(sname,sage) VALUES ('码海无际1',18);
INSERT INTO student(sname,sage) VALUES ('码海无际2',19);
INSERT INTO student(sname,sage) VALUES ('码海无际3',20);
把sname改为studentname
SELECT sid,sname AS studentname,sage FROM student;
再把sage改为studentage
SELECT sid,sname AS studentname,sage AS studentage FROM student;