Jump to content

deleted some specifique in mysql using php


Miko

Recommended Posts

Hi,

 

I have some records that contains a certain value that needs to be deleted.

Let me explain:

 

In my database I have a certain amount of records with in one of the columns a or in most cases multiple values.

 

example of some records:

header column a | header column b | header column c
bla bla bla | more bla bla | 1,2,4,8
this is more bla bla | even more bla bla | 1,5,9,6,2,7

 

what I want to do is deleted the values '1' and '2' and keep the others, so in other words, I don't want to delete those records, I want keep them and only delete the value '1' and '2', in the first record (header not counted) I should have '4,8' after my query.

This I want to accomplish with PHP.

 

I'm thinking using a LEFT JOIN in my query for this?

 

you should change your database structure. Storing comma separated values isn't a good idea

store each number as a separate row

header column a | header column b | header column c
bla bla bla | more bla bla | 1
bla bla bla | more bla bla | 2
bla bla bla | more bla bla | 4
bla bla bla | more bla bla | 8
etc

then

delete from table where columnc in(1,2)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.