Jump to content

Recommended Posts

I have the following query;

UPDATE thatsact_tagamers.tag_user SET membergroupids=CONCAT(IFNULL(membergroupids,''),IF(LENGTH(IFNULL(membergroupids,''))>0,',',''),'11') WHERE username='$vbid'

 

Is there a way to alter this where it does not insert to this field if it doesn't find the applicable $vbid at all?

 

If needed here is the full PHP code;

mysql_query("UPDATE thatsact_tagamers.tag_user SET membergroupids=CONCAT(IFNULL(membergroupids,''),IF(LENGTH(IFNULL(membergroupids,''))>0,',',''),'11') WHERE username='$vbid';");

Link to comment
https://forums.phpfreaks.com/topic/239487-if-where-not-found-do-not-update/
Share on other sites

From what I remember, this code updates the field with ,11 (with comma) if the if it contains other values, but if it is empty it just inserts the 11 (without comma). The format for this field is 1,3,5,7,11 and so on.

 

EDIT: I understand what your saying now. It does indeed actually insert a new row if $vbid is not found. I want to prevent it from doing this.

 

I am confusing myself.  :confused: What I realize is if the $vbid is for example Bob and it doesn't find Bob then it wont update anything. However, if $vbid is blank it will insert a new row. How can I prevent this?

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.