insert into products(prod_id,prod_name,pro_price)values(‘avno1‘,‘.5 ton anvil‘,5.99); insert into products(prod_id,prod_name,pro_price)values(‘avno2‘,‘1 ton anvil‘,9.99); insert into products(prod_id,prod_name,pro_price)values(‘avno3‘,‘2 ton anvil‘,14.99); insert into products(prod_id,prod_name,pro_price)values(‘ol1‘,‘oil can‘,8.99); insert into products(prod_id,prod_name,pro_price)values(‘fu1‘,‘fuses‘,3.42); insert into products(prod_id,prod_name,pro_price)values(‘slite‘,‘sling‘,4.49); insert into products(prod_id,prod_name,pro_price)values(‘tnt1‘,‘tnt (1 stick)‘,2.50); insert into products(prod_id,prod_name,pro_price)values(‘tnt2‘,‘tnt (5 stick)‘,10.00); insert into products(prod_id,prod_name,pro_price)values(‘fb‘,‘bird seed‘,10.00); insert into products(prod_id,prod_name,pro_price)values(‘fc‘,‘carrots‘,2.50); insert into products(prod_id,prod_name,pro_price)values(‘safe‘,‘safe‘,50.00); insert into products(prod_id,prod_name,pro_price)values(‘dtntr‘,‘detonator‘,13.00); insert into products(prod_id,prod_name,pro_price)values(‘jp1000‘,‘jetpack 1000‘,35.00); insert into products(prod_id,prod_name,pro_price)values(‘jp2000‘,‘jetpack 2000‘,55.00); -- 创建products表 -- 检索单个列 -- 向customers表cust_id列插入数据 create table ven |
深入理解: select * from student; ------------------------------------------ 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 ( ------------------------------------------ insert into student(sname,score,ccid) values(‘wpq2‘,93,1); insert into student(sname,score,ccid) values(‘wpq3‘,45,1); |
数据库笔记6:检索,排序检索,过滤数据