spanster90 Posted June 16, 2011 Share Posted June 16, 2011 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';"); Quote Link to comment https://forums.phpfreaks.com/topic/239487-if-where-not-found-do-not-update/ Share on other sites More sharing options...
savister Posted June 16, 2011 Share Posted June 16, 2011 Unless I'm not understanding you correctly, the code you posted already will not update the membergroupid field if $vbid is not found. Quote Link to comment https://forums.phpfreaks.com/topic/239487-if-where-not-found-do-not-update/#findComment-1230264 Share on other sites More sharing options...
spanster90 Posted June 16, 2011 Author Share Posted June 16, 2011 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. 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? Quote Link to comment https://forums.phpfreaks.com/topic/239487-if-where-not-found-do-not-update/#findComment-1230329 Share on other sites More sharing options...
spanster90 Posted June 16, 2011 Author Share Posted June 16, 2011 I do not know where this came from. Somehow it happened a few times before but does not appear at all now. I will go ahead and close this thread to save my own embarrassment. Quote Link to comment https://forums.phpfreaks.com/topic/239487-if-where-not-found-do-not-update/#findComment-1230332 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.