<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2654.45">
<TITLE>RE: [TLUG]: mysql question</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=2>There is a post you might be interested in, <A HREF="http://www.experts-exchange.com/Databases/Mysql/Q_20920874.html" TARGET="_blank">http://www.experts-exchange.com/Databases/Mysql/Q_20920874.html</A></FONT>
</P>

<P><FONT SIZE=2>I know SQL92 doesn't support insert on duplicate key. So it must be MySQL specific.</FONT>
</P>

<P><FONT SIZE=2>-----Original Message-----</FONT>
<BR><FONT SIZE=2>From: phil [<A HREF="mailto:phillip-l+pbsqP8NtUm29vl6s1fFg@public.gmane.org">mailto:phillip-l+pbsqP8NtUm29vl6s1fFg@public.gmane.org</A>] </FONT>
<BR><FONT SIZE=2>Sent: October 7, 2004 12:56 PM</FONT>
<BR><FONT SIZE=2>To: tlug-lxSQFCZeNF4@public.gmane.org</FONT>
<BR><FONT SIZE=2>Subject: Re: [TLUG]: mysql question</FONT>
</P>
<BR>

<P><FONT SIZE=2>On Oct 7, 2004, at 11:33 AM, hui xu wrote:</FONT>
</P>

<P><FONT SIZE=2>> I had a project which need to insert email addresses into mysql table</FONT>
<BR><FONT SIZE=2>> with a condition, For example, If the email address is already in the </FONT>
<BR><FONT SIZE=2>> mysql table, Do not insert it into MYSQL table. otherwise insert into </FONT>
<BR><FONT SIZE=2>> mysql table.</FONT>
<BR><FONT SIZE=2>></FONT>
<BR><FONT SIZE=2>> Can anybody tell me how to do it?</FONT>
</P>

<P><FONT SIZE=2>The simple way is first to try to retrieve a record with that email </FONT>
<BR><FONT SIZE=2>address.  If the retrieval succeeds, don't write it.</FONT>
</P>

<P><FONT SIZE=2>...or, probably better, make the address a 'UNIQUE' field and then deal </FONT>
<BR><FONT SIZE=2>with the error when you try to add it a second time.</FONT>
</P>

<P><FONT SIZE=2>...or, when MySQL supports triggers, do it as a stored procedure.  </FONT>
<BR><FONT SIZE=2>(I've been using PostgreSQL more than MySQL lately, so I'm not sure </FONT>
<BR><FONT SIZE=2>which MySQL versions have which features.)</FONT>
</P>

<P><FONT SIZE=2>........................</FONT>
<BR><FONT SIZE=2>Phillip Mills</FONT>
<BR><FONT SIZE=2>Multi-platform software development</FONT>
<BR><FONT SIZE=2>(416) 224-0714</FONT>
</P>

<P><FONT SIZE=2>--</FONT>
<BR><FONT SIZE=2>The Toronto Linux Users Group.      Meetings: <A HREF="http://tlug.ss.org" TARGET="_blank">http://tlug.ss.org</A></FONT>
<BR><FONT SIZE=2>TLUG requests: Linux topics, No HTML, wrap text below 80 columns How to UNSUBSCRIBE: <A HREF="http://tlug.ss.org/subscribe.shtml" TARGET="_blank">http://tlug.ss.org/subscribe.shtml</A></FONT>
</P>

<P><FONT SIZE=2>!DSPAM:41657576311341669238724!</FONT>
</P>

</BODY>
</HTML>