How our SQL state­ment works

Linux User & Developer - - Tutorial -

The the daunt­ing, un­der­stand its the Fig­ure con­stituent main simpler SQL 5, state­ment which im­age but state­ment once it parts. pro­duces might be­comes we shown break First, look shown eas­ier out­put in a it con­sider bit up in into to like that be­tween sec­ond stand­alone shown and the in SQL fourth brack­ets Fig­ure state­ment, lines) 6. (be­tween Ev­ery­thing could as be long the a as ac­tual we re­placed Video ID, Video.ID such as 'zoo'. with This an state­ment num­ber of key­words would then from re­turn the the set 'el ephant','flamin­gos','carousel' that match the 'zoo' video.

Now, if we put this whole ex­pres­sion in brack­ets and treat it as though it were a col­umn in the Videos ta­ble, we can get the num­ber of ta­ble matches by in­sert­ing for ev­ery Videos.ID video in in the place of 'zoo'. Adding AS Matches at the end gives a name to this tem­po­rary com­puted col­umn – Matches, com­plet­ing Fig­ure 5. It’s not too hard to get from here to the code in the main im­age. The OR­DER BY con­straint tells the database to or­der the re­sults by the num­ber of matches, while the HAV­ING clause re­moves all rows where the num­ber of matches is 0. Last, we re­place the ac­tual key­words with a list of place­hold­ers (for ex­am­ple, ?,?,?). Since the num­ber of key­words might change, we need to write some Go code that will gen­er­ate the right num­ber of ques­tion marks for these place­hold­ers.

Newspapers in English

Newspapers from UK

© PressReader. All rights reserved.