Link to home
Start Free TrialLog in
Avatar of dgrafx
dgrafxFlag for United States of America

asked on

insert to mysql table

what is the syntax to insert a record only if the record doesn't already exist?
say its based on a column named 'testname'
ASKER CERTIFIED SOLUTION
Avatar of Aaron Tomosky
Aaron Tomosky
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dgrafx

ASKER

the uniqueness is determined by a combo of userid and testname

i need the syntax
the code i would use on sql server is appearing to fail

what i'd normally use is something like
INSERT INTO sometbl
(x,y)
SELECT 'x','y'
WHERE NOT EXISTS (Select 1 from sometbl where x='x' and y='y')

thanks
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dgrafx

ASKER

ok - thanks a lot guys
i will test it later - i cant right now
Avatar of dgrafx

ASKER

thanks a lot guys