Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP MySQL Query to get most popular from two different tables
    primarykey
    data
    text
    <p>I have two tables afrostarprofiles and afrostarvvideos created as shown below. artistid field in afrostarvideos is the primary id of afrostarprofiles. I want a single query that will return for me most popular afrostarprofile based on sum of views(afrostarvideo) and views of afrostarprofiles. i basically need an algorithm or query that will rank afrostarprofiles based on total views of videos from afrostarvideos and views from afrostarprofiles. Is this possible. i know i can do this with php processing sql results but i think there is a more efficient way with mysql. any help is appreciated</p> <pre><code> $ct_members="CREATE TABLE `afrostarprofiles` (". "`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,". "`name` TEXT NOT NULL ,". "`country` TEXT NOT NULL ,". "`piclocation` TEXT NOT NULL ,". "`views` INT NOT NULL ,". "`date` INT NOT NULL );"; mysql_query($ct_members); $ct_members="CREATE TABLE `afrostarvideos` (". "`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,". "`name` TEXT NOT NULL ,". "`url` TEXT NOT NULL ,". "`views` INT NOT NULL ,". "`artistid` INT NOT NULL ,". "`date` INT NOT NULL );"; mysql_query($ct_members); </code></pre> <p>example of table structure of afrostarprofiles</p> <pre><code>4 Jose Chameleon Uganda afrostarpics/4.jpg 10 1287082754 3 Ziggy Dee Uganda afrostarpics/3.jpg 44 1286494407 </code></pre> <p>examples of afrostarvideo profile</p> <pre><code>12 Tebamatila www 11 3 1287136275 13 Mamba Mtu www 14 3 1287136524 14 TECHNOLOGY www 15 4 1287170779 125 Jamila www 14 4 1287387760 </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload