update one table from another table

Ads
 

update one table from another table

hello, i need to update one table fields by using another table fields. I have to tables Products and ProductsPurchased,as i add any item to ProductsPurchased, all the fields related to that items in Products (like ProductName ,TotalQuantity,TotalPrice) should be updated. for example TotalQuantity field from Products table should be updated if i enter the Quantity field in table 'Products_Purchased'In table 'Products' one item should be shown only once. i tried this one but it gives null outpot for TotalQuantity.here is my code

update products as a,productspurchased as b set a.totalquantity=

case

when a.dateoflastupdate < b.PurchaseDate

then (select * from (select sum(products.totalquantity)+sum(productspurchased.quantity) from products natural join products_purchased)as c)

else a.total_quantity

end

where a.productname=b.productname ; share|edit

View Answers

Ads









Related Tutorials/Questions & Answers:
update one table from another table
update one table from another table  hello, i need to update one table fields by using another table fields. I have to tables Products.... for example TotalQuantity field from Products table should be updated if i
take data from one table and insert same in another
take data from one table and insert same in another  I want to know when a new field update in table and the same data has to update in another table
Advertisements
copying data from one table to another
copying data from one table to another  i need to copy data from one table to another table.. i.e the 1st eid of employee table must be copied to the 1st eid in appusers table, 2nd eid of employee to the 2nd eid of appusers
retrieve the records from one table to another table by using cursors
retrieve the records from one table to another table by using cursors  ... from one table to another table by using cursors.The following is my procedure and tables.After execution it insert one extra record to another table. empproc
mysql select into table from another table example
from one table into another table. Check the example at MySQLselect into new...mysql select into table from another table example  Can you suggest the correct example of select into table from another table example in MySQL
How to compare two tables, and insert values which r not in one table to another table?
How to compare two tables, and insert values which r not in one table to another table?  Hi I need to compare two tables MainTable and OUTTable... MT (MT.serialno) values (Select SerialNo Main_Table MT from where not exists
Adding a flex table in another flex table column
Adding a flex table in another flex table column  how to add a flex table in another flex table column
how to count unique and duplicate values from one table in mysql?
how to count unique and duplicate values from one table in mysql?  I have use EMP table.I want to count unique and duplicate records from emp table and how to use in java program
MYSQL - mysql copy table to another table example by creating new table
MYSQL - mysql copy table to another table example by creating new table ... a new table with all the data from this table. How to create a new table... the query: create table <newtable> select * from <old table>; Example
How to update table in Hibernate
How to update table in Hibernate  Hi, I have a table in database that has two fields in it. Student Name and ID, can anyone explain me how to update these tables in Hibernate. Thanks.   Update table query in Hibernate
Foreign key update table
Foreign key update table  How to update table that has the foreign key in SQL..?   ALTER TABLE YourTable ADD CONSTRAINT FK_YourForeignKey... (YourPrimaryKeyColumn) ON UPDATE CASCADE
How to update table column from the values of Arraylist in java
How to update table column from the values of Arraylist in java  Hii Sir, I have an arraylist containing these values [2, 1, 1, 1, 1, 1, 1... column of database table. plz give me the code of this problem.Thank you Sir
how to insert one table to anothere table
how to insert one table to anothere table  i have insert the record one table then i retrve the value of that table i insert one value at a time
how to move records from one table to other based on its creation time
how to move records from one table to other based on its creation time  Hi all,, As part of my requirement ,the records in one table have to move... to the second table,has to delete from first table.. I am using oracle10, Any suggestions
can we update table in hibernate with out primary key in table?
can we update table in hibernate with out primary key in table?  can we update table in hibernate with out primary key in table
update a particular of mysql table using servlet
update a particular of mysql table using servlet  how to update a particular column for the entire table by taking requests from html form and update the particular column with out affecting other attribute values in the tuple
Server side validation on dynamically generated fields from more than one table on spring framework.
Server side validation on dynamically generated fields from more than one table on spring framework.   Server side validation on dynamically generated fields from more than one table in spring mvc framework
retrieve record from table
for a single record. I have to retrieve these data from the field table. Actually...retrieve record from table  Hi. I have a field in database named... chennai as one value, trichy as one value. and i have to show it in html. how
how to get multiple hyperlink values from a table column to another jsp file?
how to get multiple hyperlink values from a table column to another jsp file... file named "dbtable" will get the parameter from "index" and search for the user string in the database, as a result a table will come up with 3 columns itemid
how to insert the bulk data into the data base from the table of jsp page to another jsp page
how to insert the bulk data into the data base from the table of jsp page to another jsp page  pls help i'm doing the project called centralized... and i have to insert the mark for n number student in the table i don't how
Pls provide me jsp code to get values in drop down list from another table's field....
Pls provide me jsp code to get values in drop down list from another table's field....  my project has customer registration and company registration pages..... when i insert data in company registration .. it ll have company id
Adding button to each row for the table and adding row to another table
Adding button to each row for the table and adding row to another table  Hi I need to add button to each line in the table(Table data is retrived... row of the table
how to update table using inner joins
how to update table using inner joins  how to update table using inner joins
table
table  multiplicatyion table
table?
can't figure out, how to construct a table,with two fixed columns, one that reads...table?  Hi, how could i make a table in javascript, which would look... (from the user). Last two need mathematical inteference which I can do, but i
Mysql From Table
Mysql From Table       Mysql From Table is used to specify the table from which the records... for From The keyword 'from' is used to specify the table 'Stu' from which records
table
input from oracle table(my database table..) This is a very important table of my
delete row from a table in hibernate
delete row from a table in hibernate  is there method to delete row in a table using hibernate like save(-) to insert row
print the multiplication table up to one
print the multiplication table up to one  My problem is that I have... be the highest one. An example: if the user tells the program that the highest...; System.out.println("Enter an integer to print it's multiplication table
calling one jsp from another jsp page
calling one jsp from another jsp page  need coding for calling one jsp from another jsp including the xml file.Its urgent
Table
Table  How i generate table in showMessageDialog. I want that i creat a table and run in showMessageDialogeprint("cprint("code sample");ode sample

Ads