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?

 

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.