INSERT INTO tabelle2 SELECT DISTINCT * FROM tabelle1;
|
|
SELECT * from Zustaende AS t1
INNER JOIN Zustaende AS t2
ON t1.zahl<t2.zahl AND t1.id=t2.id
DELETE FROM Zustaende WHERE zahl IN (1222, 3434, 2321 ...)
|
|
DELETE FROM table1
USING table1, table1 as vtable
WHERE (NOT table1.ID=vtable.ID)
AND (table1.field_name=vtable.field_name)
1. Here you tell mysql that there is a table1.
2. Then you tell it that you will use table1 and a virtual table with the values of table1.
3. This will let mysql not compare a record with itself!
4. Here you tell it that there shouldn’t be records with the same field_name
|
|
delete from table1 where id in (
select t2.id
from table1 t1
join table1 t2 on t1.id < t2.id and t1.name = t2.name
)
|
|
|
|
|
|