Link to home
Start Free TrialLog in
Avatar of dimensionav
dimensionavFlag for Mexico

asked on

How to get the last record ?

HI

I have a table that contains payments related to an order (IdOrder, IdPayment, Amount, Date), in that table can be zero, one or more payments with different IdPayment and I need to create an sql query that returns the last IdPayment.

Regards.
ASKER CERTIFIED SOLUTION
Avatar of Kyle Abrahams, PMP
Kyle Abrahams, PMP
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dimensionav

ASKER

PayMent works like an alias?
If you want to get last idPayment(Means that was entered first) for an order you can do like this:(Using mysql sql query)

select IdPayment from <table> where orderId = 123 order by date limit 1