SQL通配符选择

时间:2017-03-02 16:56:59

标签: sql postgresql

我正试图从数据库中寻找纳税申报表,所以我添加了如下的where子句

WHERE  (memo LIKE '%TAX%'AND memo NOT LIKE '%TAXI%')
OR memo NOT LIKE '%IRS%'
OR memo LIKE '%BOFI RAC%'
OR memo LIKE '%EPS RFND%'
OR memo LIKE '%REPUBLIC TRS RT FED%'
OR memo LIKE '%TA PAYMENT%'
OR memo LIKE '%JTHF-EA JTHF ADV%'
OR memo LIKE '%REFUND ADVANTAGE ELEC REFND%'
OR memo LIKE '%TAX PRODUCTS PE3%'

但是,会弹出PAYPAL TRANSFER个结果。

对此有何想法?

1 个答案:

答案 0 :(得分:0)

我想你想要:

WHERE (memo NOT LIKE '%IRS%' AND
       (memo LIKE '%TAX%'AND memo NOT LIKE '%TAXI%') OR
        memo LIKE '%BOFI RAC%' OR
        memo LIKE '%EPS RFND%' OR
        memo LIKE '%REPUBLIC TRS RT FED%' OR
        memo LIKE '%TA PAYMENT%' OR
        memo LIKE '%JTHF-EA JTHF ADV%' OR
        memo LIKE '%REFUND ADVANTAGE ELEC REFND%' OR
        memo LIKE '%TAX PRODUCTS PE3%'
       )
      )