I want to delete values that are not from a specific set of values. I don't know these values in advance. I can know these values by querying them & I want to do the process in one step. I did the following statement:
delete from db.table1 where domain not in
(
select distinct domainname
from db.table1
where domainname like '%.uci.edu'
group by keyvalue
order by domainname
)
and domainanme like '%.uci.edu';
Knowing that the domainname
is a unique field, and the primary key for table1
is auto_increment
number.
What I need to do is the following: I have a list of domain names. say: aa.yahoo.com, bb.yahoo.com, cc.yahoo.com, aa.msn.com. Each domain name has a key value. If the key is shared, I want to delete this record. So, I selected the distinct values grouped them by the key value. If the record in not in the distinct set, and have the same top level domain, then I don't need it.
I might be wrong in my query. SQL gives me error: 1093: you can' specify target table table1 for update in FROM clause.
Please, help in achieving this purpose by any efficient way. I have a very long list of sheared top level domain names, I only need the ones with distinct key value. If there is a universal solution that will do this without the need of going on every domain name one by one (like my example) that is better.
EDIT: domainname
is NOT unique field. I use another field: domainnameNo
as unique field