Solved

How to get the last record ?

Posted on 2012-03-28
3
330 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 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Split wordpress loop 35 56
PHP error function not working on AWS 10 74
php help 34 58
reverse engineer .sql from php files 11 35
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Creating and Managing Databases with phpMyAdmin in cPanel.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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…

830 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