Tuesday, 15 May 2012

How matched tags percentage can be calculated in mysql with php -


I have 3 tables, the first one is a playlist, there are two other keywords and keywordmaps.

To use the SQL below to search for the playlist that I share the normal tag I need to get my tag and order in mysql + php even if i I can match the tag count, then I can calculate the percent in php later.

Tables are; Order playlist, keyword, keyword map

  | Pid | Authorid | Totaltrack | | Baby Words | Experiment | Created | | Kimid | KVID | Plidd |  

Previous code;

  SELECT p1.pid keywordmap left from the playlist p1 ON kimi.plld = p1.pid where (p2 left from the playlist p2 selected for pdp, the keyword mapps p2 at km2 Pid = km2.plid LEFT JOIN Keywords kws at km2.kwid = kws.kid WHERE p2.pid = 10) plidded by group  

are desired results;

  | Plid | MatedTag | Percentage | 234 | 23 65 | 363 | 21 | 55 | 19. 18 | 34 91 | 1 | 3  

So here's the answer. Remaining percentage calculation based on user's total tag count

  select p1.pid, match as COUNT (plid), p1.authorid keymap km to the left Playlist p1 ON km.plD = P1 .pad where in queue ( Connect with selective quiddet from PDP to playlists Keywordsmap2p2.pid = km2.plid on km2 left keyword kws km2.kwid = kws.kid WHERE p2.pid = $ pid) DESC matched by plaid order by group  

No comments:

Post a Comment