Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8824081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:31:07+00:00 2026-06-14T06:31:07+00:00

I’m just stuck with a simple mysql query, I want to update the row

  • 0

I’m just stuck with a simple mysql query, I want to update the row having max Id of a table, and I was trying something like but it doesn’t work

UPDATE inbox i
INNER JOIN messages m ON i.message_id = m.id 
SET i.read = 0
WHERE m.conversation_id = 10
AND i.user_id = 1
ORDER BY i.id DESC
LIMIT 1

I’ve also tried sub query but it doesn’t work either

Need some help on it.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T06:31:09+00:00Added an answer on June 14, 2026 at 6:31 am

    In MySql you can’t update a table if you have a subquery that references the same table, but you could sostitute the subquery with JOINS. I would do this, it’s a trick but it works:

    UPDATE
      inbox inner join (select max(id) as maxid from inbox) mx on inbox.id = mx.maxid
    SET inbox.`read` = 0
    

    EDIT: I see you edited your question, so i have to edit my answer:

    UPDATE
      inbox
      INNER JOIN (select max(inbox.id) as maxid
                  from
                    inbox inner join messages
                    on inbox.message_id = messages.id
                  where
                    messages.conversation_id=10
                    and inbox.user_id=1) mx
      on inbox.id = mx.maxid
    SET inbox.`read` = 0
    

    Your subquery returns the maximum id based on the conversation_id and the user_id you want, then you join inbox whith the maximum id to select just the row you want, and you can then update just that row.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to render a haml file in a javascript response like so:
I have two tables with like below codes: Table: Accounts id | username |
For some reason, after submitting a string like this Jack’s Spindle from a text
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I've got a string that has curly quotes in it. I'd like to replace
I want use html5's new tag to play a wav file (currently only supported

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.