Jump to content

PHP MYSQL: Find and update columns beginning with...


lindm

Recommended Posts

Trying to build a tiny but effective script that removes database data for all columns beginning with cx.

 

It is relating to storing checkbox status. Since an unchecked checkbox doesn't send data I need to "reset" all stored checkbox values before sending new checkbox data.

 

Any suggestions?

Link to comment
Share on other sites

Tried the query but get unknown column error.

 

I have say 20 columns all with the name beginning with cx:

 

cxTEST

cxTEST2

cxTEST3

 

etc

 

Is there a simple query to empty all columns? I tried

 

UPDATE table SET x ='' WHERE x LIKE 'cx%'

 

but no go.

 

 

Link to comment
Share on other sites

But isn't that impossible. I want x to refer to all columns that begin with cx. Instead of writing

 

SET cx1 = '', cx2 ='' etc..

 

I want to write

 

SET all columns that begin with cx to ''. Can't see how your query can work...

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.