NYCPHP Meetup

NYPHP.org

[nycphp-talk] Hmmm...still not quite there :-(

Rolan Yang rolan at omnistep.com
Mon Dec 5 23:56:35 EST 2005


Anthony Papillion wrote:

> Thanks to everyone who responded to my SQL syntax question. However, 
> for some strange reason, I am STILL getting an error. So far, I've 
> modified my SQL statement the following ways:
>
> SELECT * FROM sisters WHERE email != 'email address' ORDER BY RAND() 
> LIMIT 1
>
> SELECT * FROM sisters WHERE email NOT 'email address' ORDER BY RAND() 
> LIMIT 1
>
> SELECT * FROM sisters WHERE email NOT LIKE 'email address' ORDER BY 
> RAND() LIMIT 1
>
> SELECT * FROM sisters WHERE email IS NOT LIKE 'email address' ORDER BY 
> RAND() LIMIT 1
>
> SELECT * FROM sisters WHERE email <> 'email address' ORDER BY RAND() 
> LIMIT 1
>
> None, of these statements work and yet they all look (at least to me) 
> syntactically correct. Could this be a problem with my db server??
>
> Anthony
>
try

select * from sisters where email <> 'email address' order by 
rand(unix_timestamp()) limit 1;

However, this page mentions that using rand may not be the best idea.
http://www.titov.net/2005/09/21/do-not-use-order-by-rand-or-how-to-get-random-rows-from-table/

~Rolan



More information about the talk mailing list