Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2010
    Posts
    136

    Unanswered: select statement to get the all data with last sr_number save

    Hi..

    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

    Code:
    SELECT last_insert_id(sr_number), sr_date, Items, SubItems, ItemCode, DemandedQty FROM stock_requisition;
    it display all data from my database.

    Code:
    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 :

    1204100002

    I attach my sample data from my database:

    Thank you so much
    Attached Thumbnails Attached Thumbnails get last sr_numberv01.jpg  

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    LAST_INSERT_ID() returns the value of the last auto_increment immediately after an INSERT

    you do not have an INSERT
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •