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

Thread: update

  1. #1
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,994
    Thanks
    120
    Thanked 76 Times in 76 Posts

    update

    Code:
    id_1   id_2     date
    1        2        1 
    1        2        2 
    1        3        3
    want to update in such way that all id_2 becomes 2 based on fact that
    date is minimal at that id_2, within id_1.

    How to do that, mysql does not seem to suport min(something) in joins or subselects .
    Found a flower or bug and don't know what it is ?
    agrozoo.net galery
    if you don't spot search button at once, there is search form:
    agrozoo.net galery search

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Um... what?

    So you want to update that last row, making the "3" a "2" in id_2? And this is based on the value of id_2 where min(date) grouped by id_1?

    I would do that with a SELECT query and then an UPDATE query. Any compelling reason you have to do it in one query?


  •  

    Posting Permissions

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