[nycphp-talk] OT: Quick MySQL Syntax Question
Hans Zaunere
lists at zaunere.com
Mon Dec 5 23:04:17 EST 2005
> I know this is off-topic but this problem is driving me totally nuts and
> I am hoping somone here will take a moment to answer this post:
Not so much - but there is also a MySQL-SIG - http://www.nyphp.org/lists
> I have a db table called 'sisters'. I am wanting to select ONE RANDOM
> record from that table but I want to exclude a specific record from that
> random selection. Here is the sql I'm using:
>
> SELECT * FROM sisters WHERE email !='email_address_to_exclude' ORDER BY
> RAND() LIMIT 1"
The typical SQL syntax for not-equal is <> (that's less-than followed by
greater-than).
[re-adjusting no quoting]
> > IS NOT LIKE
In this case, MySQL will interpret NOT LIKE the same as <> assuming there
are no special chars. So it's important to note if there are any type of
wildcards. For instance, a percent sign will cause your expression to act
differently in a variation of LIKE vs. a basic string match using a
variation of an equal sign. And not all databases (IIRC) do this, so you
should always use a strict match unless you want wildcards to sneak in.
---
Hans Zaunere / President / New York PHP
www.nyphp.org / www.nyphp.com
More information about the talk
mailing list