MySQL 5.5 Community Server
MySQL 5.6 Community Server
Percona Configuration Wizard
XtraBackup 搭建主从复制
Great Sites on MySQL
Percona
MySQL Performance Blog
Severalnines
推荐管理工具
Sequel Pro
phpMyAdmin
推荐书目
MySQL Cookbook
MySQL 相关项目
MariaDB
Drizzle
参考文档
http://mysql-python.sourceforge.net/MySQLdb.html
cs5117155
V2EX  ›  MySQL

求一个 mysql 语句同时满足两列的条件进行筛选

  •  
  •   cs5117155 · Jan 23, 2021 · 2448 views
    This topic created in 1974 days ago, the information mentioned may be changed or developed.
    SELECT `o`.`id`,`o`.`pay_type`,`o`.`operation_id`,`o`.`order_no` FROM `pay_auth_log` `o` WHERE  `o`.`status` < 99  AND `pay_status` <= 1;
    

    这条语句怎么改为,当pay_type=2 && operation_id为空的时候就过滤改条信息,但是pay_type=1时,operation_id为空时,该记录需要展示出来。 截图

    5 replies    2021-01-26 22:19:59 +08:00
    eason1874
        1
    eason1874  
       Jan 23, 2021   ❤️ 1
    `pay_type` = 1 OR (`pay_type` = 2 AND `operation_id` IS NOT NULL)
    easonzhang666
        2
    easonzhang666  
       Jan 23, 2021
    and ((xx ) or (xx))
    cs5117155
        3
    cs5117155  
    OP
       Jan 23, 2021
    good
    deargodfrey
        4
    deargodfrey  
       Jan 23, 2021 via Android
    mysql 能用 not 吗如果有的话就只要加个 AND NOT (paytype=2 and operationid is null)
    cs5117155
        5
    cs5117155  
    OP
       Jan 26, 2021
    @deargodfrey 这个也不错
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2452 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 11:31 · PVG 19:31 · LAX 04:31 · JFK 07:31
    ♥ Do have faith in what you're doing.