Should be simple....
Ok, so I am adding data to a field.
If the field is null add a value. If the field is not null, add the value prepended with a comma.
So I tried this to make sure it worked, but it doesn't:
The above was just for a simple test, not the statemnet I would use.
SELECT IF(IS NULL(`vg_user_data`.`friends_list`), '2', ',2')
Now why would that not work?
If 'IS NULL' returns true, select '2' else select ',2'.
Problem is I get this error every time:
I could check the field first, but why use two db calls when I should be able to do it in one?!
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IS NULL(`vg_user_data`.`friends_list`), '2', ',2')' at line 1
Thanks for any help.
Last edited by CrazyMerlin; 02-26-2007 at 12:21 AM.
Okay forget the above....doh!
IS NULL is not a function....doh!
is what I needed!
SET `friends_list` = IF(`friends_list` IS NULL, '3', CONCAT(`friends_list`, ',3'))
WHERE `user_idx` = 1
Last edited by CrazyMerlin; 02-26-2007 at 12:30 AM.
IFNULL() is perhaps what you where looking for...
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)