The Arcive of vBulletin Modifications Site. |
|
|
#1
|
|||
|
|||
|
How do I join a count from another table? I want to list all users and to see how many photos (stored in a separate table) a particular user has submitted. Can someone show me the MySQL syntax? Thanks!
|
|
#2
|
|||
|
|||
|
someone?
|
|
#3
|
||||
|
||||
|
something like:
SELECT count(*) as total FROM user, photos WHERE user.userid=photo.userid GROUP BY photo.userid |
|
#4
|
|||
|
|||
|
okay...thanks!
|
|
#5
|
|||
|
|||
|
errrr...how can i merge this with a regular query to list all the users?
|
|
#6
|
|||
|
|||
|
yeah so it freddie or someone could show me an example of how to list all members and for each one show how many photos they have in a table called "userphotos", i would very much appreciate it
thanks
|
|
#7
|
||||
|
||||
|
This would only list those with at least one photo
SELECT count(*) as total , user.username FROM user, photos WHERE user.userid=photo.userid GROUP BY photo.userid or this would show all users, putting 0 for those with none. SELECT count(*) as total , user.username FROM user LEFT JOIN photos USING (userid) GROUP BY photo.userid |
|
#8
|
|||
|
|||
|
can you show me how to use that in a php script? lol
|
|
#9
|
||||
|
||||
|
]
Code:
<? SELECT count(*) as total , user.username FROM user, photos WHERE user.userid=photo.userid GROUP BY photo.userid ?> Code:
<? SELECT count(*) as total , user.username FROM user LEFT JOIN photos USING (userid) GROUP BY photo.userid ?> |
|
#10
|
|||
|
|||
|
never mind! i see it now!
|
![]() |
|
|
| X vBulletin 3.8.12 by vBS Debug Information | |
|---|---|
|
|
More Information |
|
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|