SQL基本操作

https://www.sqlteaching.com   SQL练习网站

 

SELECT * FROM friends_of_pickles  返回所有行和列

SELECT name,gender FROM friends_of_pickles  返回name,gender的所有行和列

SELECT * FROM friends_of_pickles WHERE species = 'dog';  返回 species为dog的所有行和列

SELECT * FROM friends_of_pickles WHERE height_cm < 45; 返回height_cm小于45的所有行和列

 

SELECT * FROM friends_of_pickles WHERE height_cm >= 45; 返回height_cm大于等于45的所有行和列

SELECT * FROM friends_of_pickles WHERE height_cm >= 45 AND species= 'human'; 返回height_cm大于等于45并且species=human的所有行和列

 

SELECT * FROM friends_of_pickles WHERE height_cm >= 45 OR species= 'human';返回height_cm大于等于45或者species=human的所有行和列

SELECT * FROM friends_of_pickles WHERE  species IN ('human','dog'); 返回species在human,dog中的所有行和列

SELECT DISTINCT gender FROM friends_of_pickles WHERE  species IN ('human','dog'); 返回species在human,dog中的物种的gender并去重

SELECT * FROM friends_of_pickles ORDER BY name 返回按name的升序排序所有的行和列

 

SELECT * FROM friends_of_pickles ORDER BY name DESC; 返回按name的降序排序所有的行和列

SELECT * FROM friends_of_pickles ORDER BY name DESC LIMIT 2;  返回按name的降序排序前两行的行和列

SELECT COUNT(*) FROM friends_of_pickles;  返回所有的行数

 

posted @ 2018-11-14 10:37  篓子  阅读(198)  评论(0编辑  收藏  举报