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 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









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
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
Advertisements
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
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
Copy One Database Table to Another
Copy data from one database table to another! 4 row(s)affected... Copy One Database Table to Another   ... to another database table. That means we copy one table to a different table
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
one frame update another frame
one frame update another frame  How do I make a link or form in one frame update another frame
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 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 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 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
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
Display table performing action on another table
Display table performing action on another table In this section, we have created two tables. The data in table 1 have shown as a result of the database... of the table row, another table will be displayed showing the data of that row
how to update table using inner joins
how to update table using inner joins  how to update table using inner joins
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
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
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
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
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
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
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
table
table  multiplicatyion table
redeploy project update database table
redeploy project update database table  **Dear Sir, i am using Hibernate 3.3 and spring 3.0 and mysql database. Now while redeploying project In tomcat 6 i want to run a sql query Thanks for your wise comments
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
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
TABLE
TABLE   Why doesn't <TABLE WIDTH="100%"> use the full browser width
table
input from oracle table(my database table..) This is a very important table of my
Mysqldump one table - Taking dump of only one table
to take the backup of only one table from the database...Use of mysqldump for taking backup of one table In this section you will see the example of mysqldump function which takes the backup of only one table
Table
Table  How i generate table in showMessageDialog. I want that i creat a table and run in showMessageDialogeprint("cprint("code sample");ode sample
Mysql From Table
Mysql From Table       Mysql From Table is used to specify the table from which the records... from 'Mysql From Table'. To grasp this example we create  a table 'Stu
Copy Table in a MySQL Database
Copy data from one table to another in a database! 2 row(s)affected...;  In this section, you will learn to copy one table to another... you in copying one table to another in a same MySQL database. To copy any table
Table
Table  How I generate table in showMessageDialog. E.g 3X1=3 3X2=6 3X3=9print("code sample
Table
Table  How i generate table in showMessageDialog. I want to creat a table and run in showMessageDialoge. Pl make a table programe which run..., JOptionpane, Integer.parseInt. Please use only these above methods to make table
table
table  Hi..I have a list of links which links to a table in the same page.If I click first link the table is displayed at the top, likewise if i click the last link the table is displayed at the last,i dont know how to set
Table
Table  How i generate table in JOptionpane.showMessageDialog... advance coding but i want u make the table using JOptionpane.showMessageDialog, import.javax.swing int Integer.parseInt(). Thats my limit. Pl generata a table
Table
Table  Why u dont understand sir?? I want to make a table program which generate a table on showMessageDialog. I have learnt these methods until now... methods to be used. Write a table program which use only and only these above methods
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
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
Table
Table  How i create table on showMessageDialog using JOptionpane and Integer.parseInt. No other method to use. Pl make a program which generate 5X1=5 5X2=10 5X3=15   Hi Friend, Try this: import javax.swing.*; import
PHP MySQL Update
PHP MySQL Update       In SQL, Update is another statement which is used to update any record of a table... is as follows: update <table name> set <field-name=value,....>ADS
Total summay from a sale table
Total summay from a sale table  Total summay from a sale table
retrieve record from the field table
,kanchipuram for a single record. I have to retrieve these data from the field table...retrieve record from the field table  Hi. I have a field in database... values like chennai as one value, trichy as one value. and i have to show it in html
How to retrieve record from table
,kanchipuram for a single record. I have to retrieve these data from the field table...How to retrieve record from table  Hi. I have a field in database... like chennai as one value, trichy as one value. and i have to show it in html
File copy from one directory to another in java
File copy from one directory to another in java  I am trying to find very good code example for copying a file from one directory to another...? Is there any size issue while copying the file from one directory to another
How to forward the control from one jsp to another?
How to forward the control from one jsp to another?  Hi! This is Prasad Jandrajupalli. I have the 3 JSP's, but I want communicate with each... is not communicate with the Third JSP. I want forward the control from first jsp to second

Ads