0

I have a field called "system" in my database which looks like this

system field;

registration    //This field is part of a table called "system_owner" 
elearning       //all three value is in one string which each contains "\n"
payment

When I removed the "elearning" with this SQL statement;

$SQL = "UPDATE system_owner SET system=REPLACE(system,'elearning','')

The system field became like this;

registration

payment

My problem is how do I remove the empty space between "registration" and "payment"? What SQL statement should I use?

The output of the field that I want

registration
payment
Hafiz Abdullah
  • 248
  • 1
  • 5
  • 14
  • This is a common problem for tables not adhering to the [first normal form](https://en.wikipedia.org/wiki/First_normal_form). It's usually hard to work with such fields in SQL so a common way is to do all the work in the application code instead. Here's an example on how to do it in PHP: http://stackoverflow.com/a/11079123/238978 – Emil Vikström Jun 20 '12 at 04:47

1 Answers1

4

What if you try:

$SQL = "UPDATE system_owner SET system=REPLACE(system,'elearning\n','')
sushil
  • 2,641
  • 3
  • 18
  • 24
  • It works but when I try to display it into a textarea box, there's still empty space between them. I don't know why but in the database, the data looks exactly what I wanted. What went wrong? – Hafiz Abdullah Jun 20 '12 at 04:52
  • Can you show how you are displaying in textarea? May be its something that you are doing while displaying in the textarea. – sushil Jun 20 '12 at 05:08
  • Sorry if I'm asking too much but can you try it out? save something like mine from a textarea into database and edit the data. Then display it again into the textarea. Maybe you know what went wrong that way. – Hafiz Abdullah Jun 20 '12 at 05:26