Query: SELECT id, name, FROM users u WHERE **id <> 0** LIMIT 50 OFFSET 0
What does开发者_如何学运维 the clause id <> 0
mean here? Does it mean:
id is less than zero or id is greater than zero
<>
means "not equal" (it can also be written as !=
with some DBMS)
It means not equal and apparently I have to submit at least 30 characters for my answer.
It means, "where ID is different from 0".
So, both greater than or less than 0.
it means that you are fetching all records with an id different than 0 (zero), I've sometimes used this just to check if some record is already saved (if the record has an ID it means is saved).
It means only include results who's field id
has a value of greater or smaller than 0, basically records that have non-zero id
's - but really this should not be possible, if it is then I'd recommend reconsidering your table designs.
精彩评论