' ## COUNT MOST FAMOUS PHOTOGRAPHER
SQL = "SELECT TOP 10 u.intID, u.strNickname " _
& ", (SELECT [b]COUNT(tmpPhotos)[/b] FROM images i WHERE i.intUserID = u.intID ) " _
& " FROM users u, images i WHERE tmpPhotos > 0 ORDER BY tmpPhotos DESC;"
set mySQL = Conn.Execute(SQL)
IF NOT mySQL.EOF THEN application("listUsersTOP10") = mySQL.GetRows() ELSE application("listUsersTOP10") = ""
' ## COUNT MOST FAMOUS PHOTOGRAPHER
SQL = "SELECT TOP 10 u.intID, u.strNickname " _
& ", (SELECT [b]COUNT(*) AS tmpPhotos[/b] FROM images i WHERE i.intUserID = u.intID ) " _
& " FROM users u, images i WHERE tmpPhotos > 0 ORDER BY tmpPhotos DESC;"
set mySQL = Conn.Execute(SQL)
IF NOT mySQL.EOF THEN application("listUsersTOP10") = mySQL.GetRows() ELSE application("listUsersTOP10") = ""
' ## COUNT MOST FAMOUS PHOTOGRAPHER
SQL = "SELECT TOP 10 u.intID, u.strNickname " _
& ", (SELECT COUNT(*) FROM images i WHERE i.intUserID = u.intID ) [b]AS tmpPhotos[/b] " _
& " FROM users u, images i WHERE tmpPhotos > 0 ORDER BY tmpPhotos DESC;"
set mySQL = Conn.Execute(SQL)
IF NOT mySQL.EOF THEN application("listUsersTOP10") = mySQL.GetRows() ELSE application("listUsersTOP10") = ""
Fungerar:
& " FROM users u, images i ;"
Fungerar EJ:
& " FROM users u, images i WHERE tmpPhotos <> 0;"
& " FROM users u, images i ORDER BY tmpPhotos DESC;"
Kan jag inte använda tmpPhotos senare i urvalet...!?
select top 10
u.intId
, u.strNickName
, count(*)
from users u
inner
join images i
on u.intId = i.intUserId
group
by u.intId
, u.strNickName
having count(*) > 0
order
by 3 desc
SQL = "select top 10 u.intId, u.strNickName, count(*)" _
& " from users u " _
& " inner join images i on u.intId = i.intUserId " _
& " group by u.intId, u.strNickName having count(*) > 0 " _
& " order by 3 desc ;"
set mySQL = Conn.Execute(SQL)
IF NOT mySQL.EOF THEN
myRow = mySQL.GetRows()
FOR j = 0 TO UBound(myRow,2)
response.write j+1 & ". " & myRow(1,j) & " -- " & myRow(2,j) & "<br>"
NEXT
END IF
Men hur frågar jag "WHERE u.strNickName <> '' " ???
SQL = "select top 10 u.intId, u.strNickName, count(*)" _
& " from users u " _
& " inner join images i on u.intId = i.intUserId " _
& " group by u.intId, u.strNickName having count(*) > 0 " _
& " [b]WHERE u.strNickname <> ''[/b] order by 3 desc ;" <--- FUNGERAR EJ. Har även prövat alternativ.
SQL = "select top 10 u.intId, u.strNickName, count(*)" _
& " from users u " _
& " inner join images i on u.intId = i.intUserId " _
& " WHERE u.strNickname <> '' group by u.intId, u.strNickName having count(*) > 0 " _
& " order by 3 desc ;"
set mySQL = Conn.Execute(SQL)
IF NOT mySQL.EOF THEN
myRow = mySQL.GetRows()
FOR j = 0 TO UBound(myRow,2)
response.write j+1 & ". " & myRow(1,j) & " -- " & myRow(2,j) & "<br>"
NEXT
END IF
Tack! Gütt mos.... Vem vill ha cred för detta...!?