Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,963
    Thanks
    120
    Thanked 76 Times in 76 Posts

    update last record

    Code:
    a   b   text
    1   1   t1 
    1   2   t2 
    1   3   t3
    2   4   t4
    ...
    Code:
    update table set text = 'sometext'
    where a = 1 and b = (select max(b) from table where a = 1)
    this does not work -->

    You can't specify target table 'table' for update in FROM clause
    Last edited by BubikolRamios; 04-08-2009 at 08:19 AM.

  • #2
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,963
    Thanks
    120
    Thanked 76 Times in 76 Posts
    found something that works:

    Code:
    update table set text= 'sometext'
    where a= '1'
    order by b desc limit 1


  •  

    Posting Permissions

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