Yiling Lee

本篇為初學者自學第四篇,由於是自學筆記,撰寫角度以筆者本身需求為優先考量

菜鳥成就感 : 自己寫syntax找出解決方式,大概是最大的成就,即便這只是個小小的功能。

兩表有不相同Value,如何找出差異值且顯示出來呢?

今天的任務是要找出兩張表(languages 和 countries)不同的地方且把不同之處顯示出來。

STEP1- 觀察Languages TABLE

Original languages table- containing 955 records

可以看出來這個language Table 中有955 筆資料 但是仔細觀察後,發現每個國家有多種語言,像是表中code欄位,找到AFG後發現總共有四個AFG的資料,其中name欄位有顯示出不同名稱,我們不難猜出,這就是語言的名字。所以光是阿富汗(AFG)這個光家就有四個語言了。但我想知道在這張表中包含的所有國家,我可以怎麼把國家總數列出來呢?

這時候你需要 DISTINCT 這個commander

SELECT DISTINCT code FROM languages; 查到這張表總共有212個國家!

--

--

本篇為初學者自學第二篇,由於是自學筆記,撰寫角度以筆者本身需求為優先考量。

BETWEEN

IS NULL

IS NOT NULL

DISTINCT

LIKE

Get the names of people whose names have ‘r’ as the second letter. The pattern you need is '_r%'.

SELECT name

FROM people

WHERE name LIKE ‘_r%’;

NOT LIKE

Get the names of people whose names don’t start with A. The pattern you need is 'A%'.

SELECT name

FROM people

WHERE name NOT LIKE ‘A%’;

--

--

As soon as 和 As long as 超像 只差一個字但意識卻完全不同

As soon as = immediately after(time)

As long as = if (condition), using at present tense.

So….As long as is based on condition(if)/for the duration

As long as you give a ride, I will go to the party tonight. I will go to the party tonight as long as you give a ride.

As long as I live, I will remember you. (The time duration)

As long as you are quiet, you can come.(Condition)

As long as I am here, I will help. (The time duration)

As long as you buy me lunch, I will help(Condition).

This is the way how I jow down my note.

--

--