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 9253941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:20:37+00:00 2026-06-18T11:20:37+00:00

Can I do this to update a row? This is the first time I

  • 0

Can I do this to update a row? This is the first time I am using a LEFT JOIN with an UPDATE.

UPDATE comments AS r

LEFT JOIN items AS i 
        ON i.items_id = r.item_id
LEFT JOIN master_cat AS c
        ON c.cat_id = i.items_id  
SET r.good = r.good + 1 
WHERE i.item = '{$item}' AND c.category = '{$cat}' AND r.review = '{$review}';

It doesn’t throw an error, but it says 0 rows affected even though I have confirmed my variables are ok with right data. (Even if I hard code the data).

Edit: I have tried inner join as well, and does not work either.

Edit 2: This is actually what I am trying to do, I have these two queires and they work fine. I am trying to simplify code to one. Can this be done:

     // This query returns rate_id which I use as "$review_id" in the second query.

     $query = "
     SELECT r.rate_id
     FROM comments as r
     LEFT JOIN items AS i 
         ON i.items_id = r.item_id
     LEFT JOIN master_cat AS c
         ON c.cat_id = i.cat_id
     WHERE r.review = '{$review}' 
        AND i.item = '{$item}' 
        AND c.category = '{$cat}';"; 

    $query = "
    UPDATE comments 
    SET good = good + 1 
    WHERE rate_id = '{$review_id}';";
  • 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-18T11:20:38+00:00Added an answer on June 18, 2026 at 11:20 am

    Your problem is that in the UPDATE statement you have a mismatching join (cat_id with items_id):

    LEFT JOIN master_cat AS c
            ON c.cat_id = i.items_id  
    

    while in the SELECT (that is working), you have the join correctly:

    LEFT JOIN master_cat AS c
            ON c.cat_id = i.cat_id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My first time using triggers. Can anyone please explain why this trigger won't work?
Can this <%= link_to 'Item', {:controller => items, :action => update, :id => @item,
This is the first time I'm using jqgrid. I have confused in how to
I know that in standard SQL you can do this: update top (100) table1
How can I update this regular expression to find and replace not just /news/
In SQL Server , I can do something like this: UPDATE tbl1 SET col2
I can't figure out why this simple update command won't work: private void button1_Click(object
How do you update this environment variable at runtime so that ctypes can load
What is the script to update deployment ( from GUI, we can do this
Sorry for the double post, I will update this question if I can't get

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.