mysql question

phil phillip-l+pbsqP8NtUm29vl6s1fFg at public.gmane.org
Thu Oct 7 16:56:15 UTC 2004


On Oct 7, 2004, at 11:33 AM, hui xu wrote:

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

The simple way is first to try to retrieve a record with that email 
address.  If the retrieval succeeds, don't write it.

...or, probably better, make the address a 'UNIQUE' field and then deal 
with the error when you try to add it a second time.

...or, when MySQL supports triggers, do it as a stored procedure.  
(I've been using PostgreSQL more than MySQL lately, so I'm not sure 
which MySQL versions have which features.)

........................
Phillip Mills
Multi-platform software development
(416) 224-0714

--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list