Yes, this does what I want and does not produce an error (which caused the remaining MYSQL syntax not to be executed). The firstname, lastname was for example only. In my problem, these are two different identifiers so I am not worried about multiple dual identifiers.
Thanks to Keith Ivey, Alec Cawley, Gerald Clark and Michael Dykman for helping with this problem. I learnt a lot from the list today. Thanks! Regards, Adai. On Mon, 2004-07-26 at 18:04, Keith Ivey wrote: > Adaikalavan Ramasamy wrote: > > >This naive syntax does not work : > >IF EXISTS (SELECT myID FROM tb WHERE firstname='Jack' AND > >lastname='Doe') ELSE (INSERT INTO tb(firstname, lastname) VALUES > >('Jack', 'Doe'); > > > Assuming you have the unique index on (firstname, lastname), just do > > INSERT IGNORE INTO tb (first_name, lastname) VALUES ('Jack', 'Doe'); > > But how are you planning to handle multiple people named Jack Doe? -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]