【问题标题】:write multiple where filtering in mysql在mysql中编写多个where过滤
【发布时间】:2018-09-15 16:43:22
【问题描述】:

这样的sql怎么写?

$sqlNext = "select * from table WHERE (status='normal') AND (number = (select max(number) from table where number < 5)) LIMIT 1";

在第一步中按status 列过滤结果,然后

status='normal' 行中搜索number 值小于5 的行。

AND=>status='normal' 的这个 sql 的第一部分不工作

只需发送number 值小于 5 的最大行数

【问题讨论】:

  • 如果我正确理解您的问题,您还需要在子查询中使用status='normal' 过滤器

标签: php mysql sql multiple-conditions


【解决方案1】:

这不是你要找的吗?

select max(number), status from table WHERE status='normal' and number < 5

【讨论】:

    猜你喜欢
    • 2016-01-16
    • 1970-01-01
    • 1970-01-01
    • 2023-04-10
    • 2016-07-21
    • 1970-01-01
    • 1970-01-01
    • 2020-01-22
    • 2014-11-26
    相关资源
    最近更新 更多