首页 > 代码库 > 数据库笔记6:检索,排序检索,过滤数据
数据库笔记6:检索,排序检索,过滤数据
insert into products(prod_id,prod_name,pro_price)values(‘avno1‘,‘.5 ton anvil‘,5.99); |
深入理解: select * from student; ------------------------------------------select t.sid+1 ‘tsid加了1‘, t.sid+5, t.score+100, t.sid+t.score as ‘sid_score‘, t.*, 5*8 ‘五‘ from student t; ------------------------------------------ select t.sid, t.sname, -- 设置别名 from student t; ------------------------------------------ select t.sid, t.sname, -- 常量列 5, from student t; ------------------------------------------ select -- sid列数据加一,并创建一个t.sid+1列的数据 t.sid +1, t.sname, t* from student t; ------------------------------------------ select -- 两个整型数据相加,得出t.score+t.ccid列名的相加数据 t.score+t.ccid from student t; ------------------------------------------ select -- 整型和字符类型数据相加,得出t.score+t.sname列名的t.score数据(字符类型和整型数据相加,结果也是一样,以整型为主) t.score+t.sname from student t; ------------------------------------------ select -- 改为‘我‘列名 t.score ‘我‘ from student t; ------------------------------------------ select s.score+5 ‘q‘,s.score+s.ccid,5 ‘我‘ from student s; select t.ccid ‘加‘, ------------------------------------------ select * from student t where t.score>70 order by t.score desc limit 5; select * from student t ------------------------------------------ ------------------------------------------ select * from student;------------------------------------------ create table student (id int not null auto_increment, primary key(id) )engine = innodb; ------------------------------------------ alter table student add sname char(40); alter table student add score int; alter table student add ccid int; ------------------------------------------ insert into student(sname,score,ccid) values(‘wpq2‘,93,1); insert into student(sname,score,ccid) values(‘wpq3‘,45,1);insert into student(sname,score,ccid) values(‘QQ5‘,43,1); insert into student(sname,score,ccid) values(‘wp9‘,60,1); insert into student(sname,score,ccid) values(‘w‘,99,1); insert into student(sname,score,ccid) values(‘w123‘,91,1); |
本文出自 “烟雨平生” 博客,请务必保留此出处http://1095221645.blog.51cto.com/6507311/1433344