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

  • Home
  • SEARCH
  • 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 6564889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:01:32+00:00 2026-05-25T14:01:32+00:00

i am stuck with a simple query if someone can help me on on

  • 0

i am stuck with a simple query if someone can help me on on the same.
i want to update one field with query from another table
the table structure is as follows:-
table stockmain – fields – itemcode, avgcost
table sales – fields – itemid, saleprice, costprice(this field is to be generated with query from stockmain table(avgcost field)
the query is follows:-

$qry = "UPDATE sales SET costprice = SELECT avgcost FROM stockmain WHERE itemcode = 'sales.itemid' ";
  • 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-05-25T14:01:33+00:00Added an answer on May 25, 2026 at 2:01 pm

    You can join these two tables to get one data set, and then copy data from one field to another, e.g. –

    UPDATE sales sl
      JOIN stockmain stm
        ON stm.itemcode = sl.itemid
    SET sl.costprice = stm.avgcost;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I hope someone can help with this please. I am trying to query an
Been stuck with this fairly simple MySQL query for a day now! Can't believe
I've been stuck with this simple Sql query for last 3 hours and my
I'm stuck on a RegEx problem that's seemingly very simple and yet I can't
This is probably a simple one to answer, but I'm stuck, so here goes.
I can't believe I'm getting so stuck on what seems like such a simple
We're currently stuck trying to make a simple (?) SQL query. We have these
I want to fetch images from goolge/images again any query. I am using following
I'm stuck with a very simple criteria query problem: sess .createCriteria(user.class, user) .user_c.add(Restrictions.eq(user.status, 1))
I've stuck with this SQLAlchemy-Python problem: here's a class that should do simple update

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.