BR
asked on
merging two mysql sentence
Dear Experts,
I use PHP 7.2 and mySQL version 5.6
with below SQL I got the first entry of my users which is entered yesterday, however I also need to get the last entry of the same users which is entered yesterday,
how can I do that?
I want to show the first and the last entry of my users and their entrance time on the same table.
this sql works perfectly fine to bring the first enterance,
this sql works perfectly fine to bring the last enterance,
how can merge these two sql statements to get the data inside only one table?
thank you
I use PHP 7.2 and mySQL version 5.6
with below SQL I got the first entry of my users which is entered yesterday, however I also need to get the last entry of the same users which is entered yesterday,
how can I do that?
I want to show the first and the last entry of my users and their entrance time on the same table.
this sql works perfectly fine to bring the first enterance,
$sql = "SELECT uid,tarih FROM takip WHERE tarih >= '$raportarihi' group by uid ORDER BY `takip`.`tarih` DESC";
this sql works perfectly fine to bring the last enterance,
$sql = "SELECT uid,max(tarih) as tarih FROM takip WHERE tarih >= '$raportarihi' group by uid ORDER BY max(tarih) asc";
how can merge these two sql statements to get the data inside only one table?
thank you
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
be my guest ;)
we tend to forget such features because we usually expect the fields selected to be consistent ( pulled from the same row ) which is not the case with aggregation and group by clauses.
happy coding to you !
we tend to forget such features because we usually expect the fields selected to be consistent ( pulled from the same row ) which is not the case with aggregation and group by clauses.
happy coding to you !
ASKER
thank you