Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f1SM6Yx12410 for ; Wed, 28 Feb 2001 17:06:34 -0500 (EST) (envelope-from josh@agliodbs.com) Received: from [207.172.28.154] (HELO agliodbs.com) by davinci.ethosmedia.com (CommuniGate Pro SMTP 3.4) with ESMTP id 1211636; Wed, 28 Feb 2001 14:06:32 -0800 Message-ID: <3A9D7654.453E40A9@agliodbs.com> Date: Wed, 28 Feb 2001 14:06:12 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions X-Mailer: Mozilla 4.73 [en] (Win98; I) X-Accept-Language: en MIME-Version: 1.0 To: "Diehl, Jeffrey" , sqllist Subject: Re: mysql's "replace into..." References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200102/431 X-Sequence-Number: 1636 Jeff, > Thanx for your help. I found replace into to be a nice convience since my > primary keys are often expressions build from several fields which I want to > keep unique. Replace into enforces this uniqueness. I was learning SQL > when I started this project so I didn't know this was non-standard. Bummer. No, what you're describing are called "composite keys". They are a standard part of SQL, but most developers end up using numerical surrogate keys because they are easier to handle. > But since my primary keys are expressions, I can't use the technique you > suggested. I'm thinking of simply trying the insert and checking to see if > I get an error. If I get an error, I do an update... Not sure how well > this will work, tho. Better to do it the other way. Search for that key; if it's returned, do an update; if the results are NULL, do an insert. If your table has few fields (<15) you can even do this through a function, passing the field values as parameters of the function. -Josh Berkus -- ______AGLIO DATABASE SOLUTIONS___________________________ Josh Berkus Complete information technology josh@agliodbs.com and data management solutions (415) 565-7293 for law firms, small businesses fax 621-2533 and non-profit organizations. San Francisco