php - MySQL Script not entering correctly -
i have mysql , php script enter row when doesn't exist.
insert `tblplayerachievements` (hs_id, achievementid, achievementprogress) select * (select ".$userdata['hs_id'].", ".$achievementid.", 0) tmp not exists (select * `tblplayerachievements` hs_id=".$userdata['hs_id']." , achievementid=".$achievementid.") limit 1
this works until both $userdata['hs_id'] , $achievementid same value , skips one. how fix this?
since haven't bothered answering question happens if row exists, i'm going assume want insert
fail. in case, need create unique
index on (hs_id, achievementid)
. recommend set default value of 0
on achievementprogress
query needs specify ids create row.
Comments
Post a Comment