mysql - How to get last item for GROUP BY -


this question has answer here:

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

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -