Assuming you want current set even the first time, do it with:INSERT into forum (memberName,original) values (?,?) on duplicate key update forum set current=? where memberName=?
INSERT into forum (memberName,original,current) values (?,?,?) on duplicate key update forum set current=values(current) where memb +erName=?
if you wanted a perl solution instead (e.g. if the DB engine you're using appears not to enforce the uniqueness constraint), the idea would be to do a select first on the "contest" table for the given memberName value; if that returns a non-empty value, update the "current" field for that row; otherwise, insert a new row.The select is redundant; try the update, and if it processes no rows, try the insert.
Better yet, if the database engine you're using doesn't enforce a uniqueness constraint, get a better database system.
In reply to Re^2: database setup
by ysth
in thread database setup
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |