Jump to content

[SOLVED] replace


asmith

Recommended Posts

i'm really sorry guys to ask a simple mysql question here, but really i didn't find the answer .

the code is :

replace into tablename (field) values ('a');

 

but i want to replace a record in a specific row .

so i did :

 

replace into tablename (field) values ('a') where username = 'john' ;

 

but it give me syntax errors!

:-\ kinda in a hurry

 

Link to comment
Share on other sites

done ! i thought update do not delete last information , just add.

is there a command to write a value beside the record ?

for example in  a table , username = john .

then  i would add "1"  in the right or left of john : 1john or john1 .

(i know i could get john, put in a variable then add 1 to it ,  any sql comand instead of 3 ,4 php lines ?)

Link to comment
Share on other sites

What do you mean exactly by

is there a command to write a value beside the record ?

for example in  a table , username = john .

then  i would add "1"  in the right or left of john : 1john or john1 .

You can write anything inside that quote instead of john

WHERE 'username'='john1'; or WHERE 'username'='1john'; OR WHERE 'username'='I hate you john';

Link to comment
Share on other sites

i meant add a "string" to a record,

update delete the last record and replace that with new one    ,

i meant the new value go beside the old one ,

old value    "i hate you john"

i add    "!!!" to the field

 

so it will be " i hate you john!!!"

 

:)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.