Shreenivas
Shreenivas

Reputation: 155

how to update single data from a single column in mysql

I am inserting the cars using check boxes. i want to remove Audi car from the list . how can i achieve this one

+----+------------+-----------------+----------+---------+------------+----------+
| id | sms        | Cars            | usertype | noprice | regdate    | time     |
+----+------------+----------+----------+---------+------------+----------+------
| 82 | hello boys | BMW Audi Maruti |  Driver  | 50      | 2014-08-24 | 09:11:50 |
+----+------------+-----------------+----------+---------+------------+----------+

Expected result

+----+------------+------------+----------+---------+------------+----------+
| id | sms        |   Cars     | usertype | noprice | regdate    | time     |
+----+------------+----------+----------+---------+------------+----------+--
| 82 | hello boys | BMW Maruti | Driver    | 50      | 2014-08-24 | 09:11:50|
+----+------------+------------+----------+---------+------------+----------+

Upvotes: 1

Views: 22

Answers (1)

M Khalid Junaid
M Khalid Junaid

Reputation: 64466

You can use replace() function to update your column

update table set cars = replace(cars ,'Audi','') where id = 82

Demo

Or its better to relate cars with single user in a separate table with car name and associated user id ,each car and user relation in a separate row

Upvotes: 1

Related Questions