Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Decreasing numbers in SQL

 
shuzo monsoon
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello! What I'm trying to do at the moment is have a query which finds the appropriate record of a particulat product in the STOCK table and then decrement that quantity by 1. However, I'm not sure ntirely how to do this, as I know how to change the number by specifying one but I'm not sure how to minus the number. I tried this :

But this doesn't work because the second QuantityInStock is not recognised. Has anyone any ideas?
Thanks!
 
Blake Minghelli
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the STCOK table has a column called "QuantityInStock" then you can do this:
 
eammon bannon
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

But this doesn't work because the second QuantityInStock is not recognised
[/qoute]
Can you explain what you mean by this? Are you getting a SQLException, or is the variable undefined? It looks like it should work fine to me, though you appear to probably be using a SQL varchar datatype for QuantityInStock, despite treating it as numeric.
 
shuzo monsoon
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Blake! That worked. Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic