Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 522
  • Last Modified:

Mysql sate ment deduct onetable from another table

I have 2 tables table 'product' and  'sale'  how can I write sql statement to deduct sale item from table product
0
teera
Asked:
teera
  • 3
1 Solution
 
honestman31Commented:
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
 
teeraAuthor Commented:
update product,sale set produt = ( product.ProductQuantity - sale.quantity)


I try like this but it not work
0
 
honestman31Commented:
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
 
honestman31Commented:
Also you need to provide the joint  filed ,
 what field represents the relation between the two tables ,
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now