vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   Select Random User for Contest (https://vborg.vbsupport.ru/showthread.php?t=49158)

XtReMaTriX 02-21-2003 02:21 PM

Select Random User for Contest
 
Hey,
I have been trying to figure out how to do this. I have a contest going on in my forum Win a Cooler Master ATC-710 GX1 Case and i need to select a user with 15 or more posts and who has started at least 2 threads. Is there a way to randomly select this user? Has anyone else needed to do this???

filburt1 02-21-2003 02:27 PM

With MySQL 4 it would be easy with subselects but here's a MySQL 3 way. It returns the userid and username of one user who has both made 15 posts and created one thread. I don't know how to modify it to use two other than using subselects (MySQL 4).
[sql]
SELECT u.username, u.userid FROM user u, thread t
WHERE u.posts > 15 AND t.postuserid = u.userid
ORDER BY RAND() LIMIT 1;
[/sql]

Xenon 02-21-2003 02:38 PM

hmm, not sure, but i think this can work for two thread
(it's not a nice way but should do it:)

[sql]SELECT u.username, u.userid FROM user u, thread t, thread t2
WHERE u.posts > 15 AND t.postuserid = u.userid AND t2.postuserid=u.userid AND t.threadid!=t2.threadid
ORDER BY RAND() LIMIT 1;[/sql]

filburt1 02-21-2003 02:42 PM

Yeesh that's filthy but it looks like it should work. :)

BTW both queries are really server-intensive so don't run them too often. My iBook's load average right now is 0.48 and it took 1.5 seconds to run the query using a week or two old WDF database dump.

XtReMaTriX 02-21-2003 03:00 PM

wow, thanks guys... very fast reply... looks like it will work GREAT! i am going to test it out now...


All times are GMT. The time now is 10:59 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00939 seconds
  • Memory Usage 1,714KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete