mysql - 开始按特定行条件进行查询

标签 mysql sql

我有一个 mysql 表,其中列是 post_id 和 post_msg。现在我想从 post_id 列中值为 3 的行开始查询。作为此查询的结果,从 post_id 3 (ASC) 开始的所有行都将成为结果集。 我该怎么做?

 post_id | post_msg   
   1     |   heheh   
   2     |   hi   
   3     |   hello 
   4     |   hoho  
   5     |   hayhay   
   6     |   harhar

从该表中,我想从具有 post_id 且其值为 3 的行开始查询 我知道使用 LIMIT 但由于某些原因我的要求实际上是使用 post_id 。 这可能吗?

最佳答案

你可以尝试///如果我错了请纠正我

select post_id , post_msg from 
table1 where post_id > = '@post_id_val'
group by post_id ,post_msg
order by post_id

我得到的问题是你想显示 post_id 大于或等于 @post_id_val 的行.. 以 post_id 升序排列..

关于mysql - 开始按特定行条件进行查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9919398/

相关文章:

mysql root密码忘记了

MySQL INSERT IGNORE 不起作用

mysql - 我如何在我的 postman 中产生多个错误消息

mysql - 为什么在 Laravel 5.8 中创建外键失败?

SQL Server - 定义中的 View 名称与实际 View 名称不同

mysql - CakePHP 使用 %like% 和空格查找查询

mysql - 获取表中最新行的最佳实践

MySQL 将行格式化为列

sql - 使用 sp_executesql 返回 null 的存储过程输出参数

MySql – 查询以获取上下文结果