Common SQL command summary learn - <1>

SQL Learning Network training records

参考1:http://sample.jimstone.com.cn/xsql/Course/4.html
参考2:http://sample.jimstone.com.cn/xsql/Course/

  1. This course requires: a lookup table of all user content
    select * from user;

  2. Requirements lesson: inquiries from the user table all the data of the score is greater than 80
    select * from user where score> 80 ;

  3. Requirements lesson: gender field in the lookup table for all user content 'M' to
    select * from user where gender = 'M';

  4. 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';

  5. 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%';

  6. This course requires: user queries all fields in the table of contents contains students 'Cong' word
    select * from user where students like ' % % Cong';

  7. 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);

  8. 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 ';

  9. 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;

  10. 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';

  11. Requirements lesson: Get user table field in the average score of the
    SELECT AVG (score) from user;
    SELECT user from score;

  12. Requirements lesson: Get user table in total score of the score field
    select sum (score) as sumvalue from user;

  13. Requirements lesson: Get user table field in the maximum score
    select max (score) as maxvalue from user;

  14. Requirements lesson: Get user table field in the minimum score
    select min (score) as minvalue from user;

  15. 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;

  16. 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;

  17. 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;

  18. This course requires: list of all fields in the record added User
    INSERT INTO User (Students., Score, Gender) values ( 'snail', '100', 'M');

  19. Lesson requirements: the user table field for the students 'Bob' field where change score 30 minutes
    update user set score = 30 where students = ' Bob';

  20. This course requires: Remove the user table field for the students 'Bob' recording
    delete from user where students = 'Bob';

  21. 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));

  22. Requirements lesson: the 'test' table deletion
    drop table test;

Guess you like

Origin www.cnblogs.com/passzhang/p/12152567.html
Recommended