sorry miss some column my table is and data:
0010066, 32, Wicam, NotInterest, 2014-02-01 0010066, 32, Wicam, Discusing, 2014-02-05 0010066, 32, Wicam, Interest, 2014-02-08 0010066, 32, Wicam, Pending , 2014-02-21 0010596, 32, United, Interest, 2014-02-08 0010606, 32, SEACAM, NotInterest ,2014-03-08 0040025, 16, SkyView, Interest , 2014-03-17
I use query below:
$uer_id='$_GET[user_id]'; $remark='$_GET[remark]'; $query = $link->query("SELECT * FROM (SELECT *FROM tbreport where user_id='$uid' ORDER by date DESC ) tbreport GROUP BY comcode");
the result show the last record :
0010066, 32, Wicam, Pending , 2014-02-21 0010596, 32, United, Interest, 2014-02-08
0010606, 32, SEACAM, NotInterest ,2014-03-08 0040025, 32, SkyView, Interest ,2014-03-17
what I need the result like this
0010596, 32, United, Interest, 2014-02-08
0040025, 32, SkyView, Interest ,2014-03-17
And when $remark= 'Pending' should show like below
0010066, 32, Wicam, Pending , 2014-02-21
so how would I do more? Thanks, if have any query Sary
SELECT m1.* FROM tbreport m1 LEFT JOIN tbreport m2
ON (m1. comname = m2. comname AND m1.date < m2.date)
WHERE m2.date IS NULL and m1.remark='$remark';
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.