jeudi 4 mai 2017

Making if null then ignore else date range (mysql)

I want to make an if statement to not filter out those which has NULL idBillingTransaction

so something like, if idBillingTransaction is not null then daterange else, there should be no filter for the date range in idBillingTransactions (because it has nulls)

Here is the code

select * 
from subscription cs
  LEFT JOIN
  billing_transaction bt
    ON CONVERT(cs.msisdn USING latin1) = bt.msisdn 

    where 
      bt.idBillingTransaction
      BETWEEN (SELECT idBillingTransaction
               FROM transaction_ids
               WHERE dt = '2017-03-31')
      AND (SELECT idBillingTransaction
           FROM transaction_ids
           WHERE dt = '2017-04-30')

Aucun commentaire:

Enregistrer un commentaire