打开phpstudy软件;点开 MySQL命令行;
先创建个数据库;create database websecurity;
显示出数据库;show databases;
选择数据库;
use websecrity;
创建表单;create table student( id int(4) not null primary key auto_increment, name char(20) not null, sex char(20) nou null, addr char(20) not null ) ;
显示表单;show tables;
由于表单中没有数据,所以我们添加数据;
插入表单信息;insert into 表单(信息)values (内容); // insert into student(name,sex,addr) values ('leo','male','hangzhou'); insert into student(name,sex,addr) values ('leoo','male','hangzhou'); insert into student(name,sex,addr) values ('leooo','female','hang'); insert into student(name,sex,addr) values ('leoooo','female','hang');
再创建个teacher的表单(如上所示)
union select(合并表单);//不显示重复数据
union all // 显示重复数据select * from teacher where sex='male' union all select * from student where sex='male'
order by(排序);select * from teacher order by name; select * from teacher order by 2; "2"代表是第二列的意思;
select * from teacher where sex='male' union all select * from student where sex='male' order by 2; (合并表单后按第二列排序)
注释;#zhushi-- zhushi (–后面有括号)