Hi, I need a query to run into my mysql databse to find and replace if a condition is met. Basically I want to- Find and replace the text 'xord' with 'xord4' in the campaign column but only if the network column = content My table is called KW The code I have so far is below, but how do I tell it to only replace xord if the campaign column = content? update KW set campaign = replace(campaign, ‘xord’, ‘xord4’) Code (markup):
Here's the sql: UPDATE KW SET KW.campaign = "xord4" WHERE (((KW.network)="content") AND ((KW.campaign)="xord")); PHP: The above code assumes that the network field is literally the string 'content'. If you meant content to be a variable then you should adjust it as such.
The above would only work if the entire value of the column is 'xord'. If the column contains a string 'there is a xord...', the above would not apply. Which are you trying to accomplish?
That code doesnt work sorry =\ Yes the entire campaign column is currently set to 'xord' However where the network column is equal to 'content' I want to replace 'xord' with 'xord4' Thanks for your time
ahhh I tried it again and it worked, not sure what I did wrong the first time. Thanks for all your help guys!