Home » SQL & PL/SQL » SQL & PL/SQL » Update Statement
Update Statement [message #229718] Mon, 09 April 2007 20:09 Go to next message
pradkuamr
Messages: 29
Registered: November 2006
Junior Member
Hi

I am having a table(Table A) with the list of IDs.
I am having another table (Table B) which has IDs, amounts...Deleted Flag columns.

Table A contains the list of IDs with which we need to lookup in Table B and mark them as deleted. I need to update the Deleted Flag for that particular record to "Y" else "N"

I am thinking of simple DML Update Statement. But I am anot sure of how to include this within a single Query.

Does this work. I guess not.

Update Table B
Set Deleted_Flag='Y'
where TableA.ID=(Select ID from TableB)

Plz share your ideas

[Updated on: Mon, 09 April 2007 21:14]

Report message to a moderator

Re: Update Statement [message #229726 is a reply to message #229718] Mon, 09 April 2007 21:09 Go to previous messageGo to next message
BlackSwan
Messages: 25046
Registered: January 2009
Location: SoCal
Senior Member
>Ifthere is any ID missing in table B, I need to update the Deleted Flag for that particular record to "Y" else "N"
HUH?
If there is any ID missing in table B, then there is NO record to UPDATE!

The statement above ignores the fact that your UPDATE statement will generate a syntax error.
Re: Update Statement [message #229729 is a reply to message #229726] Mon, 09 April 2007 21:13 Go to previous messageGo to next message
pradkuamr
Messages: 29
Registered: November 2006
Junior Member
Sorry for my typo

Table A contains the list of IDs with which we need to lookup in Table B and mark them as deleted

Re: Update Statement [message #229734 is a reply to message #229718] Mon, 09 April 2007 21:30 Go to previous messageGo to next message
BlackSwan
Messages: 25046
Registered: January 2009
Location: SoCal
Senior Member
Please start over, restating the actual problem; plus posting DESCRIBE of both tables.

Regardless of everything else, I think your UPDATE statement has syntax error.

[Updated on: Mon, 09 April 2007 21:31] by Moderator

Report message to a moderator

Re: Update Statement [message #229738 is a reply to message #229718] Mon, 09 April 2007 21:49 Go to previous messageGo to next message
pradkuamr
Messages: 29
Registered: November 2006
Junior Member
I am having a table(Table A) with the list of IDs.
I am having another table (Table B) which has IDs, amounts...Deleted Flag columns.

Table A contains the list of IDs with which we need to lookup in Table B and mark them as deleted. I need to update the Deleted Flag for that particular record to "Y" else "N"

I am thinking of simple DML Update Statement. But I am anot sure of how to include this within a single Query.

Does this work. I guess not.

Update Table B
Set Deleted_Flag='Y'
where TableA.ID=(Select ID from TableB)

Plz share your ideas
Re: Update Statement [message #229740 is a reply to message #229718] Mon, 09 April 2007 21:58 Go to previous messageGo to next message
BlackSwan
Messages: 25046
Registered: January 2009
Location: SoCal
Senior Member
Do you want to flag as deleted EVERY & ALL IDs which exist in TableA?
Re: Update Statement [message #229741 is a reply to message #229718] Mon, 09 April 2007 22:00 Go to previous messageGo to next message
pradkuamr
Messages: 29
Registered: November 2006
Junior Member
yes.

Re: Update Statement [message #229743 is a reply to message #229718] Mon, 09 April 2007 22:08 Go to previous messageGo to next message
BlackSwan
Messages: 25046
Registered: January 2009
Location: SoCal
Senior Member
>Update Table B Set Deleted_Flag='Y' where TableA.ID=(Select ID from TableB)
Above is really close so experiment until you get it to work.

Re: Update Statement [message #230084 is a reply to message #229743] Tue, 10 April 2007 16:45 Go to previous message
Bill B
Messages: 1484
Registered: December 2004
Senior Member
anacedent wrote on Mon, 09 April 2007 22:08
>Update Table B Set Deleted_Flag='Y' where TableA.ID=(Select ID from TableB)
Above is really close so experiment until you get it to work.



I will give you one hint. look at the second "=" in your update command.
Previous Topic: cast-ing question
Next Topic: to get different format of dates for the user input
Goto Forum:
  


Current Time: Fri Dec 09 00:07:59 CST 2016

Total time taken to generate the page: 0.12643 seconds