Comments - select based upon date...

10 years, 11 months ago Elena Stepanova

Hi,

It depends on what you are trying to get. Your query in its current form is equivalent of

SELECT AMOUNT, TRANSACT, transDate FROM ALESSAND 
WHERE 
( transDATE > '2010-09-30' AND TRANSACT = 'DEPOSIT' ) OR 
( TRANSACT = 'WITHDRAW FUNDS' );

That is, it will select all DEPOSIT transactions of date > 2010-09-30 and all WITHDRAW FUNDS transactions of any date. But I suppose it's not what you want. More likely, you are trying to select all transactions of date > 2010-09-30 which are either DEPOSIT or WITHDRAW FUNDS, in which case you're missing the brackets:

SELECT AMOUNT, TRANSACT, transDate 
FROM ALESSAND 
WHERE transDATE > '2010-09-30' AND ( TRANSACT = 'DEPOSIT' OR TRANSACT = 'WITHDRAW FUNDS' );
 
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.