MySQL
文章平均质量分 75
bestallen
Beyond Yesterday
展开
-
SQLZOO 练习答案 SELECT_basic_names
www.sqlzoo.net 这网站不错,值得收藏 Basic篇 name continent area population gdp Afghanistan Asia 652230 25500100 20343000000 Albania Europe 28748 2831741 1296000原创 2016-12-15 21:37:42 · 4433 阅读 · 0 评论 -
SQLZOO JOIN operation
1:Modify it to show the matchid and player name for all goals scored by Germany. To identify German players, check for: teamid = 'GER' SELECT matchid,player FROM goal WHERE teamid='GER'; 2:Show原创 2016-12-31 12:21:16 · 2501 阅读 · 0 评论 -
SQLZOO SUM and COUNT
1:展示世界的總人口。 SELECT SUM(population) FROM world; 2:列出所有的洲份, 每個只有一次。 SELECT DISTINCT continent FROM world; 3:找出非洲(Africa)的GDP總和。 SELECT SUM(gdp) FROM world WHERE continent = 'Africa';原创 2016-12-26 17:07:49 · 1944 阅读 · 0 评论 -
SQLZOO SELECT FROM NOBEL
1: 更改查詢以顯示1950年諾貝爾獎的獎項資料。 SELECT yr, subject, winner FROM nobel WHERE yr = 1950; 2:顯示誰贏得了1962年文學獎(Literature)。 SELECT winner FROM nobel WHERE yr = 1962 AND subject = 'Literature'; 3:顯示“原创 2016-12-18 10:31:42 · 2433 阅读 · 0 评论 -
MySQL ORDER BY 排序 IF 及 IN
在做sqlzoo的时候,碰到一个SQL的排序问题,他把符合条件的单独几行,可以放在查询结果的开始,或者查询结果的尾部 通过的方法就是IN语句(也可以通过IF语句) 自己做了个测试,如下,这个是表的所有内容 使用ORDER BY配合IF语句 比如我想将species为snake的行数,单独列出来,我可以这样查询 SELECT * FROM pet ORDER BY原创 2016-12-18 12:33:30 · 14641 阅读 · 5 评论 -
SQLZOO USING NULL
1:List the teachers who have NULL for their department. SELECT name FROM teacher WHERE dept IS NULL 2:Note the INNER JOIN misses the teachers with no department and the departments with no tea原创 2017-01-03 15:26:43 · 1461 阅读 · 0 评论 -
SQLZOO MORE JOIN OPERATION
1:List the films where the yr is 1962 [Show id, title] SELECT id,title FROM movie WHERE yr = 1962; 2:Give year of 'Citizen Kane' SELECT yr FROM movie WHERE title='Citizen kane'; 3:Li原创 2017-01-03 12:57:17 · 3698 阅读 · 0 评论 -
SQLZOO SELECT within SELECT
这个章节是SELECT 嵌套环节 1: List each country name where the population is larger than that of 'Russia'. SELECT name FROM world WHERE population > (SELECT population FROM world WHERE name='Rus原创 2016-12-22 16:06:25 · 1940 阅读 · 1 评论 -
SQLZOO 练习答案 SELECT FROM world
name continent area population gdp Afghanistan Asia 652230 25500100 20343000000 Albania Europe 28748 2831741 12960000000 Algeria Africa 2381741 37100000原创 2016-12-16 15:28:50 · 16120 阅读 · 3 评论 -
SQLZOO SELF JOIN
1: How many stops are in the database SELECT COUNT(*) FROM stops 2:Find the id value for the stop 'Craiglockhart' SELECT id FROM stops WHERE name = 'Craiglockhart' 3:Give the id and the原创 2017-01-13 13:52:18 · 3059 阅读 · 0 评论