Solved

How to get the last record ?

Posted on 2012-03-28
3
339 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 40

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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to implement server side field validation and display customized error messages to the client.
Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read on. . .
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

717 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