简体   繁体   English

如何在MySQL中使用不大于运算符

[英]How to use not greater than operator in mysql

Does mysql support !<= or !>= operator!!! mysql是否支持!<=或!> =运算符!!! I am trying to fetch the data from the Person table where the age of a person is not greater than 30 (the age field may have null value). 我正在尝试从人的年龄不大于30(年龄字段可能为空值)的人表中获取数据。

You may phrase not greater than 30 as being aged 30 or younger: 您可以说30岁以下的人不超过30岁:

SELECT *
FROM Person
WHERE age <= 30;

By default, those records with a null age would not be included in the above inequality. 默认情况下,这些具有null龄的记录将不包括在上述不等式中。

If you really wanted to use NOT , then we could try: 如果您真的想使用NOT ,那么我们可以尝试:

SELECT *
FROM Person
WHERE NOT age > 30;

But typically you will just see the appropriate inequality being used, without an explicit NOT . 但通常情况下,您会看到正在使用适当的不等式,而没有显式的NOT

Not greater than can be written as <= 不大于可以写为<=

!<= is not an operator !<=不是运算符

Why not doing something like this : 为什么不做这样的事情:

SELECT * FROM table WHERE id <= 100

That mean the query will selecting the ID which not GREATER THAN 100. Or if you want to search something with specific value, you can try this : 这意味着查询将选择不大于 100的ID。或者,如果您要搜索具有特定值的内容,可以尝试以下操作:

SELECT * FROM table WHERE id >= 50 AND id <= 100

That mean the query will search data from table which ID is MORE THAN 50 AND NOT GREATER THAN 100 . 这意味着查询将从表中搜索ID 大于50并且大于100的数据

Hope this will help. 希望这会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM