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' ";
You can join these two tables to get one data set, and then copy data from one field to another, e.g. –