update query with select query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • thomas msofe
    New Member
    • Jan 2012
    • 1

    #1

    update query with select query

    hello there;

    im trying to use the following piece of code but it doest work,

    UPDATE itermdesc SET qnty = ( SELECT qnty -1
    FROM itermdesc
    WHERE itermcode =1001 )
    WHERE itermcode =1001

    it display the following error

    You can't specify target table 'itermdesc' for update in FROM clause

    Any quick help would be much appreciated!
    thanx
  • C CSR
    New Member
    • Jan 2012
    • 144

    #2
    try something like: UPDATE itermdesc SET qnty = (qnty -1)
    WHERE itermcode =1001.

    get rid of the statement inside the statement.

    Comment

    Working...