Solved

Mysql sate ment deduct onetable from another table

Posted on 2011-03-06
4
513 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
ID: 35052532
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
ID: 35053032
update product,sale set produt = ( product.ProductQuantity - sale.quantity)


I try like this but it not work
0
 
LVL 10

Expert Comment

by:honestman31
ID: 35053277
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
ID: 35053332
Also you need to provide the joint  filed ,
 what field represents the relation between the two tables ,
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

770 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