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" <steve@stripped>
Sent: Friday, August 20, 2010 3:30 PM
To: <mysql@stripped>
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
>
>
| Thread |
|---|
| • query help | Steven Buehler | 20 Aug |
| • Re: query help | Travis Ard | 21 Aug |