Jump to content

Most Viewed Profile Page


mattyvx

Recommended Posts

SQL Server version: 5.0.85

 

Table 1 : ID,Name,*..other fields which are not applicable*

Table 2 : ID,Profile,Website

_______________________________________________

 

Hi,

 

See above info for my setup. Table 1 stores member information. Table 2 stores how many times a users profile and website have been visited via my website (integers).

 

What i want to do is select a list of the top 5 viewed members - by top viewed i mean : (Profile visits + Website visits)

 

Any suggestions would be appreciated.

Link to comment
https://forums.phpfreaks.com/topic/187142-most-viewed-profile-page/
Share on other sites

I doubt that that is the true solution all you are doing is sorting by profile + your query is the same as mine except you use sum and order by another field. Try:

 

SELECT t1.Name, sum(t2.Profile + t2.Website) as total
FROM table2 AS t2
JOIN table1 AS t1 USING (ID)
ORDER BY total DESC
LIMIT 5

It seems neither method works :S

 

Using

SELECT t1.name, sum(t2.Profile + t2.Website) as total
FROM table2 AS t2
JOIN table1 AS t1 USING (ID)
ORDER BY total DESC
LIMIT 5

 

For example if i have two members

           

Table 1

---------

ID  Name

1  John

2  Ian

---------

 

Table 2

---------

ID |  Profile  | Website

1        12          1

2          2            9

 

What im getting as a result is:

Ian (24 visits)

 

So its summing all the values and associating them with on ID...

 

Any idea?

 

What I want is

 

John (13)

Ian  (11)

 

(sorted by "total")

 

Thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.