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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:45:50+00:00 2026-06-04T19:45:50+00:00

I have had a read through a few of the other issues around joining

  • 0

I have had a read through a few of the other issues around joining on SQL Updates but haven’t been able to finalise a query.

System is all in MySQL (INNODB table structure)

We are wanting to update an amount in one table that will increase an amount based on 2 variables from another table. There are a few constraints that need to be checked in the update to make sure the variables from the second table match the keys in the table to be updated

UPDATE as1
SET as1.amount = as1.amount + (b1.workers * b1.level)
FROM account_stock AS as1
INNER JOIN building AS b1 ON as1.accountID = b1.accountID
INNER JOIN building_seed AS bs1 ON bs1.buildingID = b1.buildingID
WHERE bs1.stockID = as1.stockID
AND b1.accountID = as1.accountID
AND b1.locID = as1.locID
AND b1.status = active
AND b1.gTime > 0

It’s getting an error and I can’t pick it. Sorry if it is a simple question, all my SQL is self taught so some of the habits I have aren’t very good!

  • 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-04T19:45:52+00:00Added an answer on June 4, 2026 at 7:45 pm

    MySQL syntax for UPDATE is different. There is no FROM:

    UPDATE 
        account_stock AS as1
      INNER JOIN building AS b1 ON as1.accountID = b1.accountID
      INNER JOIN building_seed AS bs1 ON bs1.buildingID = b1.buildingID
    
    SET as1.amount = as1.amount + (b1.workers * b1.level)
    
    WHERE bs1.stockID = as1.stockID
      AND b1.locID = as1.locID
      AND b1.status = active
      AND b1.gTime > 0 ;
    
      --- removed duplicate : 
      --- AND b1.accountID = as1.accountID
    

    Also: is active a column or you meant to write?: AND b1.status = 'active'

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

Sidebar

Related Questions

I have read through the documentation for Winsock2 on MSDN, but I still need
Just have read sass changelog and found out that FSSM (the gem that had
I have had this problem crop up a few times and I can't figure
I have had a look all over, but it doesn't seem as though my
I have had a few problems getting this right, so I wanted to ask
I've been developing websites for a few years now, and I've never had the
I'm a little knew to SQL & PHP and have been given the task
I've been teaching myself C for a few months when I have time, and
I have had a few development managers who don't seem to understand or appreciate
I have been making a live wallpaper and have finally succeeded so far, but

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.