G'Day All. I'm trying to do the following in a query, in mySQL. All my previous years of SQL has been on MS-SQL, and i'm having some little problems with tricky sql statements.
***** i'm trying to insert a new record if the name doesn't exist in the table. If i insert, return ID, else return 0 ***** <pseduo -sql syntax> SET NOCOUNT ON DECLARE @intPersonID INTEGER SELECT PersonID from tbl_PERSON WHERE Name = @strName SELECT @intPersonID = @@IDENTITY IF @intPersonID < 1 BEGIN INSERT tbl_PERSON (Name, Surname) VALUES ('TestName', 'TestSurname') SELECT @intPersonID = @@IDENTITY END ELSE SET @intPERSONID = 0 <end psedu untested code> I have NO idea how i can do this on MYSQL.. Any help would be extreamly appreciated. -Regards : Pure Krome- --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php