select case t.year when '2016' then @i := @i +1 when '2017' then @j := @j +1 end from table_name t,(select @i :=0,@j:=0) a ;
2017-11-01
講得挺好的,能夠讓人在宏觀上了解mysql優(yōu)化的不同視角和層次。評(píng)論里有些人嚷著要干貨,學(xué)理論,須知板凳坐得十年冷,心浮氣躁沒(méi)有任何幫助,徒增怨氣。
2017-10-30
就@wendyy貼出的鏈接,我大概翻譯一下:count()中只有結(jié)果是not null時(shí),才計(jì)數(shù)+1。比如在‘select count(year=2017) from film’中,count()里面的條件判斷的結(jié)果可能是true,也有可能是false,在數(shù)據(jù)庫(kù)中的表示就是1或者0,這兩者都不為null,屬于not null。而在條件語(yǔ)句后面加上or null,即表示當(dāng)‘or’左邊的條件判斷的結(jié)果是true時(shí),則返回1,計(jì)數(shù)+1;是flase時(shí),則返回或執(zhí)行‘or’右邊的字段或判斷,即返回null,不計(jì)數(shù)。
2017-10-18
你們發(fā)音準(zhǔn),你們技術(shù)就很好咯?技術(shù)好還過(guò)來(lái)聽(tīng)課?
2017-10-17
select count(*) ,actor.first_name
-> from actor,film_actor
-> where film_actor.actor_id=actor.actor_id
-> group by(actor.actor_id);
為什么不這樣寫
-> from actor,film_actor
-> where film_actor.actor_id=actor.actor_id
-> group by(actor.actor_id);
為什么不這樣寫
2017-10-15
有點(diǎn)混亂了 為什么不用 inner join 而是去重,還有優(yōu)化的原因也沒(méi)講。不是應(yīng)該講講優(yōu)化后減少了遍歷的次數(shù)什么的嗎,還有索引失效什么的。
2017-10-15