mercredi 27 octobre 2021

using if exist in mysql query

i have a mysql table with two date value date and date2

i need if date2 exist and if date2 > NOW() time don't show the row else show the row with date

if date2>NOW() ignore if date2 is not exist or dates <= NOW() show

for example date=01/01/2020. and date2=01/01/2022

$db->query("select * from tbl_transaction where user_id='XXXX' and (if count(date2) from tbl_transaction where user_id='XXXX') > 0 ");

Anybody knows if it's possible to use IF in that way?

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire