i just think you're lucky to get a row each time. your query returnes an
undefined number of rows.
Each row.numberhed against rand(), so sometimes a row matches, sometimes
not. rand() is not a constant, but calculated each match!
maybe you're looking for a query like:
select bid, number, title from t_board order by rand() limit 1;
gl
----- Original Message -----
From: "Churo Park" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, April 10, 2001 3:50 AM
Subject: Unexpected result from floor() and rand()
> I've made a query and got a good result like these:
>
> mysql> select bid, number, title from t_board
> mysql> where bid = 'test' and number = floor(rand()*100)+1;
> +------+--------+-----------------------+
> | bid | number | title |
> +------+--------+-----------------------+
> | test | 60 | About file attachment |
> +------+--------+-----------------------+
> 1 row in set (0.13 sec)
>
> mysql> select bid, number, title from t_board
> mysql> where bid = 'test' and number = floor(rand()*100)+1;
> Empty set (0.13 sec)
>
> But sometimes I get an unexpected result like this:
>
> mysql> select bid, number, title from t_board
> mysql> where bid = 'test' and number = floor(rand()*100)+1;
> +------+--------+---------------------------+
> | bid | number | title |
> +------+--------+---------------------------+
> | test | 71 | iVisit and other programs |
> | test | 89 | Homepage upgrade!!! |
> +------+--------+---------------------------+
> 2 rows in set (0.13 sec)
>
> The structure of the table t_board is like this:
>
> mysql> desc t_board;
> +----------+----------------------+------+-----+------------+-------+
> | Field | Type | Null | Key | Default | Extra |
> +----------+----------------------+------+-----+------------+-------+
> | bid | varchar(8) | | PRI | | |
> | number | smallint(5) unsigned | | PRI | 0 | |
> | id | varchar(8) | | | | |
> | when_d | date | | MUL | 0000-00-00 | |
> | when_t | time | | MUL | 00:00:00 | |
> | count | smallint(5) unsigned | | | 0 | |
> | title | varchar(100) | | MUL | | |
> | content | text | | | | |
> | attached | varchar(255) | | | | |
> | special | enum('Y','N') | | | N | |
> | filetype | varchar(48) | | | | |
> | gid | smallint(5) unsigned | | MUL | 0 | |
> | seq | smallint(5) unsigned | | | 0 | |
> | depth | tinyint(3) unsigned | | | 0 | |
> | subseq | smallint(5) unsigned | | | 0 | |
> | public | enum('Y','N') | | | N | |
> +----------+----------------------+------+-----+------------+-------+
> 16 rows in set (0.00 sec)
>
> And it has about 4,000 rows.
>
> What do you think is the problem? Shouldn't I have made such a query?
>
> Thanks in advance.
>
> Churo Park
>
>
>
> --MIME Multi-part separator--
>
>
> ---------------------------------------------------------------------
> Before posting, please check:
> http://www.mysql.com/manual.php (the manual)
> http://lists.mysql.com/ (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail
<[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php