Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Random images

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-03-29 : 23:55:51
Fuzzie writes "I need to generate a random photo gallery.

Here is the sql for displaying the gallery in newest to oldest order:

Dim s

s = "SELECT * "
if sc = "All" AND ss = "ALL IMAGES" then
s = s & "FROM gallery "
elseif SearCate = "All" then
s = s & "FROM gallery "
s = s & "WHERE (ImagDesc LIKE '%" & SearStri & "%') "
elseif SearCate <> "All" AND SearStri = "ALL IMAGES" then
s = s & "FROM gallery "
s = s & "WHERE "
s = s & "(ImagCat1 = '" & SearCate & "' OR "
s = s & "ImagCat2 = '" & SearCate & "' OR "
s = s & "ImagCat3 = '" & SearCate & "') "
else
s = s & "FROM gallery "
s = s & "WHERE "
s = s & "(ImagCat1 = '" & SearCate & "' OR "
s = s & "ImagCat2 = '" & SearCate & "' OR "
s = s & "ImagCat3 = '" & SearCate & "') AND "
s = s & "ImagDesc LIKE '%" & SearStri & "%' "
end if
s = s & "ORDER BY AutoNumb DESC"


I think this last line needs to be changed to make the selection of AutoNum random. I have tried this with no luck:
s = s & "WHERE AutoNumb = (SELECT AutoNumb((rand() * @RowCount) as int) + 1)"

thanks!"
   

- Advertisement -