-1
I have a query select
which receives the user date in the database MySQL
and the shape of the field is datetime
, and the PHP
treats the output and in HTML data as the date of registration of a personal consumption plan and when the plan will expire, I wonder if it is possible to create an alias for a subquery that returns the string "EXPIRED" if the expiration date of the record is 1 day or more.
The current query looks like this.
SELECT
data_cad
,data_expira
,pl_nome
FROMpl_misc
WHEREpl_id
= $Xyz LIMIT 1;
I wish I had something like AS EXPIRADO
that could return in PHP with a echo
. I really want to know if I could print ex: $Row['expired'] and print "Expired", "Not expired", you know, IF and ELSE condition inside Mysql itself.
Eliseu, I found a role in the php documentation that might help you. Please see if the Datetime::diff function helps you. Link: https://www.php.net/manual/en/datetime.diff.php
– Rodrigo Tognin
@Rodrigotognin really wanted to know if with IF, ELSE or any other way inside Mysql itself would be possible , even to run the query directly in phpmyadmin capiche.
– ElvisP
Eliseu, I just answered another user with a command that can help you. I’ll be putting the code as an example in the answer.
– Rodrigo Tognin