newphpcoder — 2012-04-09T23:34:07-04:00 — #1
I just want to know what is the code to get the last inserted row on database.
I tried max and last_insert_id yet it did not solve my problem
SELECT last_insert_id(sr_number), sr_date, Items, SubItems, ItemCode, DemandedQty FROM stock_requisition;
it display all data from my database.
SELECT max(sr_number), sr_date, Items, SubItems, ItemCode, DemandedQty FROM stock_requisition;
it only display last row.. but I need to display all data with all data with same sr_number
for example :
I attach my sample data from my database:
Thank you so much
calflowers — 2012-04-10T01:21:24-04:00 — #2
Why don't you add a specific value on sr_number such as:
SELECT sr_number=1204100002, sr_date, Items, SubItems, ItemCode, DemandedQty FROM stock_requisition;
guido2004 — 2012-04-10T01:40:28-04:00 — #3
Why don't you explain a bit better what you need. Give an example of the result you want based on the table data you posted.
newphpcoder — 2012-04-10T02:11:40-04:00 — #4
It resolved my problem:
SELECT sr_number, sr_date, Items, SubItems, ItemCode, DemandedQty FROM stock_requisition WHERE sr_number = (SELECT max(sr_number) from stock_requisition)
r937 — 2012-04-10T05:43:53-04:00 — #5
guido, why not wait a while before answering newphpcoder's questions
he always posts them on about a half dozen other forums, and often, as in this case, gets an answer from somewhere else