mysql - How to get last item for GROUP BY -
this question has answer here:
- select last row in mysql 7 answers
- mysql - select last inserted row easiest way 6 answers
i have table this:
id transaction_id auto_recurring paid_amount package_customerid 37 0 1 0 4 45 37 1 0 4 51 0 1 0 4 57 51 1 0 4 62 0 1 0 4 67 62 1 0 4
there 6 records of package_customer_id = 4. want last record of 4. in case id = 67 desired record. try select * transactions group package_customer_id
. got first record of package_customer_id = 4. i.e: id = 4 fetched result. how can id = 67 (my desired record) modifying sql?
select * transactions package_customer_id = 4 order id desc limit 1;
that shot @ it. sorry haven't tested it, leave you:)
edit:
dont forget quotes " ` " on columns name's:)
check column name package_customer_id
or package_customerid
?
Comments
Post a Comment