Solved

Mysql sate ment deduct onetable from another table

Posted on 2011-03-06
4
509 Views
Last Modified: 2012-05-11
I have 2 tables table 'product' and  'sale'  how can I write sql statement to deduct sale item from table product
0
Comment
Question by:teera
  • 3
4 Comments
 
LVL 10

Expert Comment

by:honestman31
Comment Utility
You have to Join the two tables first , so we need to know what is your joint field ,  if you can please post the schema for the two tables and just provide an example for what you want to do exactly  
0
 

Author Comment

by:teera
Comment Utility
update product,sale set produt = ( product.ProductQuantity - sale.quantity)


I try like this but it not work
0
 
LVL 10

Expert Comment

by:honestman31
Comment Utility
So you have two tables one called products  and it has a field called produt  and another once called  ProductQuantity

and you have another table called sales and it has a filed called produt  and another filed called quantity

is that true ?
0
 
LVL 10

Accepted Solution

by:
honestman31 earned 500 total points
Comment Utility
Also you need to provide the joint  filed ,
 what field represents the relation between the two tables ,
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
This video discusses moving either the default database or any database to a new volume.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now