SQL Learning Network training records
参考1:http://sample.jimstone.com.cn/xsql/Course/4.html
参考2:http://sample.jimstone.com.cn/xsql/Course/
This course requires: a lookup table of all user content
select * from user;Requirements lesson: inquiries from the user table all the data of the score is greater than 80
select * from user where score> 80 ;Requirements lesson: gender field in the lookup table for all user content 'M' to
select * from user where gender = 'M';Requirements lesson: a lookup table in the user field in the beginning of students 'small' content word
select students from user where students like '% less';This course requirements: user lookup table in the beginning of the field students not to 'small' content word
select * from user where students not like ' small%';This course requires: user queries all fields in the table of contents contains students 'Cong' word
select * from user where students like ' % % Cong';This course requires: a lookup table in the field score for all user content 98,60,92 of
select * from user where score in ( 98,60,92);Requirements lesson: a lookup table in the user field score is greater than 95 for all the content or female gender
select * from user where score> '95 'or gender =' M ';Requirements lesson: combined lookup table and user table user_ext the same id data of all
select * fom user, user_ext where user.id = user_ext.id;Requirements lesson: Get user table score is greater than the number of contents in the fields 60 of
SELECT COUNT ( ) from user WHERE score> '60 ';
SELECT from user WHERE score> '60';Requirements lesson: Get user table field in the average score of the
SELECT AVG (score) from user;
SELECT user from score;Requirements lesson: Get user table in total score of the score field
select sum (score) as sumvalue from user;Requirements lesson: Get user table field in the maximum score
select max (score) as maxvalue from user;Requirements lesson: Get user table field in the minimum score
select min (score) as minvalue from user;Requirements lesson: an acquisition table user_ext age all different fields and field aliases set to 'aged'
SELECT DISTINCT (age) AS Age from user_ext;This course requires: acquiring all data tables user_ext performed in reverse order according to the field and weight
SELECT * from user_ext Order desc by weight;Requirements lesson: an acquisition table are connected by a left user (alias t1) and Table user_ext (alias t2) the same data field id, wherein the field age greater than 9, and returns only id, Students., Age, weight these data fields
select t1.id, t1.students, t2.age, t2.weight from user as t1 left join user_ext as t2 on t2.id = t1.id where t2.age> 9;This course requires: list of all fields in the record added User
INSERT INTO User (Students., Score, Gender) values ( 'snail', '100', 'M');Lesson requirements: the user table field for the students 'Bob' field where change score 30 minutes
update user set score = 30 where students = ' Bob';This course requires: Remove the user table field for the students 'Bob' recording
delete from user where students = 'Bob';This course requires: create a file named 'test' in Table
create table test (id integer primany key , students varchar (8), score integer, gender varchar (2));Requirements lesson: the 'test' table deletion
drop table test;