Jump to content

If WHERE not found, do not UPDATE


spanster90

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?

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.