I need a database that can store urls in catagories and then randomly...

Discussion in 'Databases' started by DiscussNow, Nov 6, 2007.

  1. #1
    I need a database that can store urls in catagories and then randomly will choose an url from the catagory. The probability for each url to appear should also be able to be adjusted. Can anyone assist me in finding one or making a database similar to this?
     
    DiscussNow, Nov 6, 2007 IP
  2. garbageman

    garbageman Peon

    Messages:
    29
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    If you just want random, add "ORDER BY RAND() LIMIT 1" to the end of the table.
    Weighted will be more complicated. You can create two rows, one with the weight, and another that will count the number of times that url has been used.
    then, use "ORDER BY times / weight ASC LIMIT 1"
     
    garbageman, Nov 6, 2007 IP
  3. longcall911

    longcall911 Peon

    Messages:
    1,672
    Likes Received:
    87
    Best Answers:
    0
    Trophy Points:
    0
    #3
    What you are asking for is not a function of a database. The database simply stores data.

    The functionality you need is best handled by a script IMO. Basically, you would get all records in the category and then select one randomly. Alternatively, you can get only one at random using the RAND command in your query as garbageman points out.

    /*tom*/

    /*tom*/
     
    longcall911, Nov 6, 2007 IP