很有代表性的sql

2021-10-02 04:06:53 字數 2048 閱讀 9569

--- union all 外連線(相同的資料不覆蓋,展示所有資料)

select sid,sum(num) from 

(select sid,round(count(sid)/2) as num from f_pile where manufacture = '深圳盛弘' group by sid

union all

select sid,count(sid) as num from f_pile where manufacture not in ('深圳盛弘') group by sid

) t group by t.sid

--- union 外連線 (完全相同的資料覆蓋)

select sid,num1 from num1 

union

select sid,num2 from num2

--- left jion 左連線

select

* from

f_order fo

left join f_order_settlement fos on fo.sn = fos.sn

where

fo.createtime > '2020-01-10'

select

* from

f_user fu

left join f_order fo on fu.uid = fo.uid

left join f_order_settlement fos on fo.sn = fos.sn

where

fu.cid is not null

and fo.createtime > '2020-01-10'

--- right jion 右連線

select

* from

f_order fo

right join f_user fu on fu.uid = fo.uid

left join f_order_settlement fos on fo.sn = fos.sn

where

fu.cid is not null

and fo.createtime > '2020-01-10'

--- inner jion 內連線 (取相同的資料)

select

* from

num1 u1

inner join num2 u2 on u1.sid = u2.sid

--- 向一張表,插入查詢到的資料

insert into num1(sid,num1)

select sid,num2 from num2

--- 將一張表的資料根據條件更新到另一張表中

update num1 n1

inner join ( select sid, num2 from num2 ) n2

set n1.num1 = n2.num2

where

n1.sid = n2.sid;

--- 更新表中資料

update f_order 

set bef_eleprice = ele_price,

ele_price = 1.73,

bef_useele = useele,

repair_createtime = now(),

repair_remarke = '手動修改'

where

oid = 9631;

--- 清空表

truncate table if exists f_repair_e_order_history_20180722;
--- 刪除表

delete from f_order where uid in (181,267,353,405);

幾很有代表性的個for迴圈的練習題

摺紙 折多少次和珠穆朗瑪峰一樣高 1.一張紙的厚度是0.0001公尺,將紙對折,對折多少次厚度超過珠峰高度8848公尺 最後得到結果 2.有一對幼兔,幼兔1個月後長成小兔,小兔1個月後長成成兔並生下一對幼兔,問8個月後有多少對兔子,幼兔 小兔 成兔對數分別是多少。幼兔 1 小兔 0 成兔 0 初始值...

機器學習 代表性示例

支援向量機 support vector machine,svm 是機器學習中最為流行的監督學習方法。該方法仍被廣泛的應用於資料探勘產業。使用支援向量機方法時,它會在每類資料中尋找與其他類最接近的資料,並將其標記為標準。決策邊界就通過這些標準定義,這樣每個標記資料與邊界的歐幾里得距離之和最大。這些標...

代表性直覺 不要被細節迷惑

當我們進行決策或者是判斷的時候,有時候會直接運用 直覺 或一般性常識進行決策。這種方式的優點是省時省力,而且有的時候我們只是需要乙個粗略的答案就夠了,所以一拍腦袋就作出決定,比較美,可以得到乙個相對滿意的答案 即使答案錯了,我們也會有自我保護機制來逃避決策失敗帶來悔恨的方法 既然有利,必然有弊,這種...