fafa0 Posted August 18, 2014 Share Posted August 18, 2014 Hello I want receive "5" from column "mycol" in record with id ="20" in table "mytable" in database "mydb" I want to change "5" to "0" with "PHP" code . but I can't ? IF it possible help me ,please. as show in this pic: Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted August 18, 2014 Share Posted August 18, 2014 Help you with what? You neither posted the code nor described the problem. Remember: We're not sitting next to you, we don't see what you see. Right now, all I can say is that your database layout is broken. So your first steps would be to learn the basics of normalization and then restructure your database. Maybe that also solves your current problem (whatever that is). Quote Link to comment Share on other sites More sharing options...
fafa0 Posted August 18, 2014 Author Share Posted August 18, 2014 Help you with what? You neither posted the code nor described the problem. Remember: We're not sitting next to you, we don't see what you see. Right now, all I can say is that your database layout is broken. So your first steps would be to learn the basics of normalization and then restructure your database. Maybe that also solves your current problem (whatever that is). How can I call "5" from id=20 as show in pic . I want to update e.x.: 5 to 0 . I attached sql file too. mydb.zip Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted August 18, 2014 Share Posted August 18, 2014 You should take Jacques1 advice and normalize your data. Updating values within a value is bad practice But for now you can do the replacement using a query like UPDATE mytable SET space = REPLACE(space, ' 5 ', ' 0 ') WHERE id = 20 The query will update the row where id = 20 and replace (space)5(space) with (space)0(space) If we didn't pad 5 with spaces it will replace all instances of 5 to 0, eg 15 will become 10 Quote Link to comment 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.