Koj xav paub seb qhov twg sai dua - LEFT JOIN lossis INNER JOIN. Zoo, feem ntau INNER JOIN yuav nrawm dua vim tias nws tsuas yog xa rov qab cov kab sib tw hauv txhua lub rooj sib koom ua ke raws li kab sib koom.
Yuav ua li cas sib koom nrog sab hauv lossis sab nraud yog dab tsi?
A LEFT JOIN yog kiag li tsis nrawm dua li tus neeg sab hauv. Qhov tseeb, nws qeeb dua; los ntawm kev txhais, ib qho kev koom nrog sab nrauv (LEFT JOIN lossis RIGHT JOIN) yuav tsum ua txhua txoj haujlwm ntawm kev koom nrog hauv ib qho ntxiv rau kev ua haujlwm ntxiv ntawm null-extending cov txiaj ntsig.
Qhov twg nrawm dua los yog qhov twg?
10 Teb. Txoj kev xav, tsis yog, nws yuav tsum tsis txhob nrawm duaCov lus nug optimizer yuav tsum muaj peev xwm tsim tau ib txoj kev npaj ua tiav zoo ib yam. Txawm li cas los xij, qee lub cav database tuaj yeem tsim cov phiaj xwm ua tiav zoo dua rau ib qho ntawm lawv (tsis zoo li yuav tshwm sim rau cov lus nug yooj yim tab sis rau qhov nyuaj txaus).
Yuav ua li cas koom nrog tau zoo dua?
TLDR: Kev koom ua tau zoo tshaj plaws kuj yog qhov yooj yim koom nrog, 'Relational Algebra'. Yog tias koj xav paub ntau ntxiv txog txhua txoj hauv kev koom nrog, nyeem ntxiv. Relational algebra is the most common way of sau a query and also the most natural way to ua li.
Qhov twg nrawm dua koom lossis sib nug?
Qhov zoo ntawm kev koom nrog suav nrog tias nws ua tiav sai dua. Lub sijhawm retrieval ntawm cov lus nug uas siv joins yuav luag txhua zaus yuav nrawm dua li ntawm cov lus nug. Los ntawm kev siv kev sib koom, koj tuaj yeem ua kom lub nra hnyav ntawm cov ntaub ntawv piv txwv li, tsis yog ntau cov lus nug uas siv ib qho kev nug.