Something like this might work:

insert into domains
select a.accountid, reverse(a.domainid), a.mailname
from domains a
left outer join domains b on b.domainid = reverse(a.domainid) and b.accountid = a.accountid and b.mailname = a.mailname
where b.domainid is null;

-Travis

--------------------------------------------------
From: "Steven Buehler" <st...@ibushost.com>
Sent: Friday, August 20, 2010 3:30 PM
To: <mysql@lists.mysql.com>
Subject: query help

I am hoping that I can do this with one query, I have a table, "Domains"
with 3 columns
accountID, domainID, mailname



what I am trying to do is find all accountID's for "domainID" of 12345 and
see if a second row with "domainID" of 54321 exists for that
"accountID,mailname". If it doesn't exist, I want it to insert another row with the same accountID and mailname, but with the second (54321) domainid.



Any help would be appreciated.



Thanks

Steve



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql?unsub=arch...@jab.org

Reply via email to