首页 文章资讯内容详情

如何编写不大于MySQL查询中的值?

2026-06-04 1 花语

查询中的“不大于”可以简单地写为小于或等于(<=)。语法如下-

select * from yourTableName where yourColumnName<=yourColumnName;

让我们首先创建一个表-

create table DemoTable1480 -> ( -> StudentName varchar(40), -> StudentMarks int -> );

使用插入命令在表中插入一些记录-

insert into DemoTable1480 values(Chris,78); insert into DemoTable1480 values(Bob,45); insert into DemoTable1480 values(John,67); insert into DemoTable1480 values(Adam,56);

使用select语句显示表中的所有记录-

select * from DemoTable1480;

这将产生以下输出-

+-------------+--------------+ | StudentName | StudentMarks | +-------------+--------------+ | Chris | 78 | | Bob | 45 | | John | 67 | | Adam | 56 | +-------------+--------------+ 4 rows in set (0.00 sec)

以下是要写入的查询不大于MySQL查询中的查询-

select * from DemoTable1480 where StudentMarks <=65;

这将产生以下输出-

+-------------+--------------+ | StudentName | StudentMarks | +-------------+--------------+ | Bob | 45 | | Adam | 56 | +-------------+--------------+ 2 rows in set (0.00 sec)