Solved

How to get the last record ?

Posted on 2012-03-28
3
316 Views
Last Modified: 2012-03-28
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.
0
Comment
Question by:dimensionav
3 Comments
 
LVL 39

Accepted Solution

by:
Kyle Abrahams earned 500 total points
ID: 37778205
select max(IdPayment) PayMent from <table>
where orderId = 2134
0
 

Author Comment

by:dimensionav
ID: 37778354
PayMent works like an alias?
0
 
LVL 1

Expert Comment

by:maziqbal
ID: 37778430
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
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Creating and Managing Databases with phpMyAdmin in cPanel.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now