November 5th, 2012, 10:45 AM
Only insert if the field has no value already, otherwise skip it...
As the title suggests, I'm trying to write mysql that will only insert a value if the field is empty otherwise it will ignore it and where the playername=something.
So something like...
Insert playeridvalue into tableA into columnplayerid where playername is brute only if the column playerid is empty though, otherwise skip.
This has confused me A LOT! I'm not sure if to use if exists, insert...on duplicate key update, etc.
November 5th, 2012, 11:11 AM
UPDATE my_table SET my_column = 'something' WHERE playername IS 'another thing' AND my_column = '';
November 5th, 2012, 11:22 AM
If there if something already there I don't want it to do anything to it, I don't want it to update/replace etc. That value should only be assigned once when the player first logs in and then read from then on only.
November 5th, 2012, 11:58 AM
I don't really understand what you're after but perhaps "INSERT IGNORE" will suffice.
November 5th, 2012, 12:40 PM
As long as I leave the AND my_column = ''; blank it actually works quite nicely, thank you .