<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
I agree that there are better ways to do this.<br>
But for me this works. (legacy driven situation)<br>
<br>
INSERT INTO tbinitialisatie (col1, col2)
<br>
SELECT 'x', 'y'
<br>
FROM tbinitialisatie
<br>
WHERE not exists (select * from tbinitialisatie where col1 = 'x' and
col2 = 'y')
<br>
LIMIT 1
<br>
<br>
<br>
Pau Marc Muñoz Torres schreef:
<blockquote
cite="mid:CADFuJLjfHUMEuYTPKgG6GtJMfzJeeq3-bkt162RywRVqc7OYgg(at)mail(dot)gmail(dot)com"
type="cite">Ok , thanks Sim, now i see it<br>
<br>
P<br>
<br>
<div class="gmail_quote">2011/9/5 Sim Zacks <span dir="ltr"><<a
moz-do-not-send="true" href="mailto:sim(at)compulab(dot)co(dot)il">sim(at)compulab(dot)co(dot)il</a>></span><br>
<blockquote class="gmail_quote"
style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div style="direction: ltr;" bgcolor="#ffffff" text="#000000">
<div class="im"> On 09/05/2011 01:37 PM, Pau Marc Muñoz Torres
wrote:
<blockquote type="cite">i don't see it clear, let me put an example<br>
<br>
i got the following table<br>
<br>
molec varchar(30)<br>
seq varchar(100)<br>
<br>
where I insert my values<br>
<br>
lets image that i have a record introduced as ('ubq', 'aadgylpittrs')<br>
<br>
how i can prevent to insert another record where molec='ubq' ?<br>
<br>
thanks<br>
<br>
</blockquote>
</div>
Either put a unique constraint on molec or do<br>
insert into tbl(molec,seq)<br>
select 'ubq', 'aadgylpittrs' where not exists(select molec from tbl
where molec='ubq')<br>
</div>
</blockquote>
</div>
<br>
<br clear="all">
<br>
-- <br>
<b>Pau Marc Muñoz Torres</b><br>
<br>
Laboratori de Biologia Computacional <br>
Institut de Biotecnologia i Biomedicina Vicent Villar
<br>
Universitat Autonoma de Barcelona<br>
E-08193 Bellaterra (Barcelona)<br>
<br>
telèfon: (+34)935 86 89 39<b><br>
Email : <a moz-do-not-send="true"
href="mailto:paumarc(dot)munoz(at)bioinf(dot)uab(dot)cat" target="_blank">paumarc(dot)munoz(at)bioinf(dot)uab(dot)cat</a></b><br>
</blockquote>
</body>
</html>