Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Whats wrong with this UPDATE function

Status
Not open for further replies.

munnamian

IS-IT--Management
Apr 1, 2004
4
NO
hi there

i need to delete the txt OLD in S_NAME but it shows error
anyone :) thx in advance

update Songs SET S_NAME = REPLACE () WHERE S_NAME = 'OLD';

 
the error looks like:
"""The replace function requires 3 arguments."""
?
 
Whynot use

UPDATE Songs SET S_NAME = '' WHERE S_NAME = 'OLD';




G LS
spsinkNOJUNK@yahoo.co.uk
Remove the NOJUNK to use.
 
Just in case: that's 2 single quotes in S_NAME = ''.

It would be useful if you told us how it's not working. Is it rejecting your syntax (what error appears?), or does it give the wrong results (what does happen?)?
 
It gives no error, it just shows 0 processed tables or whatever it shows (its in norwegian so dont know what it had in the english version) i remember i had something similar ages ago and it was something similar as in the command

And ya i am using the two single quotes :)
 
Can you do a SHOW CREATE TABLE SONGS and post the result here?
 
You can ignore my previous post, it probably won't help.

What exactly are you trying to do?

If you want to change S_NAME when it contains just the text 'OLD', then LittleSmudge's solution is perfect.

If you want to eliminate the text 'OLD' wherever it appears in the field, then use:
[tt]UPDATE songs SET s_name=REPLACE(s_name,'OLD','')[/tt]
or, if you want a record count:
[tt]UPDATE songs SET s_name=REPLACE(s_name,'OLD','') WHERE s_name LIKE '%OLD%'[/tt]
 
Oh Good re-interpretation of the question Tony.

I wasn't comfortable that I was addressing the right issue but I couldn't see what else they might be trying to do.
I think you've seen through the fog now.





G LS
spsinkNOJUNK@yahoo.co.uk
Remove the NOJUNK to use.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top