breadcom Posted November 5, 2009 Share Posted November 5, 2009 This should be easy but every query I've tried hasn't worked. I have a table called locations. I want to delete the word Apple from anywhere in the field labeled categories. Currently some categories fields contain Apple, Raisin and some just Raisin. Can someone let me know the query to do this. I thought the following would do the trick. DELETE FROM 'locations' WHERE notes = 'Apple' Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/180428-solved-delete-word-from-field/ Share on other sites More sharing options...
gevensen Posted November 5, 2009 Share Posted November 5, 2009 locations should be `locations ` not 'locations' Quote Link to comment https://forums.phpfreaks.com/topic/180428-solved-delete-word-from-field/#findComment-951896 Share on other sites More sharing options...
breadcom Posted November 5, 2009 Author Share Posted November 5, 2009 Sorry I meant . . . DELETE FROM `locations` WHERE `Apple`; Quote Link to comment https://forums.phpfreaks.com/topic/180428-solved-delete-word-from-field/#findComment-951912 Share on other sites More sharing options...
gevensen Posted November 5, 2009 Share Posted November 5, 2009 Sorry I meant . . . DELETE FROM `locations` WHERE `Apple`; for example DELETE FROM `locations` WHERE `word` = `Apple`; Quote Link to comment https://forums.phpfreaks.com/topic/180428-solved-delete-word-from-field/#findComment-951914 Share on other sites More sharing options...
breadcom Posted November 5, 2009 Author Share Posted November 5, 2009 What does `word` represent? I thought that was where the field had to go which in this case is notes. That hasn't worked. I'm good at creating just not deleting I guess. Thanks for your help. Quote Link to comment https://forums.phpfreaks.com/topic/180428-solved-delete-word-from-field/#findComment-951923 Share on other sites More sharing options...
fenway Posted November 18, 2009 Share Posted November 18, 2009 Backticks and single quotes are not interchangeable. And post the actual error as well... Quote Link to comment https://forums.phpfreaks.com/topic/180428-solved-delete-word-from-field/#findComment-960090 Share on other sites More sharing options...
DavidAM Posted November 18, 2009 Share Posted November 18, 2009 Are you saying you have a table like this: Notes ===== Apple Raisin Banana Apple, Raisin Apple, Banana Mango, Apple and you want to remove the word apple from the notes field leaving the rest of the field as is? Notes ===== <BLANK> Raisin Banana , Raisin , Banana Mango, If so, you need to use the REPLACE function UPDATE locations SET notes = REPLACE(notes, 'Apple', '') WHERE notes LIKE '%Apple%' Quote Link to comment https://forums.phpfreaks.com/topic/180428-solved-delete-word-from-field/#findComment-960209 Share on other sites More sharing options...
breadcom Posted November 18, 2009 Author Share Posted November 18, 2009 Yes. Perfect. Thank you very much!! Quote Link to comment https://forums.phpfreaks.com/topic/180428-solved-delete-word-from-field/#findComment-960214 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.