Skip to content

Instantly share code, notes, and snippets.

@rubyonrailsworks
Created November 27, 2012 09:19
Show Gist options
  • Save rubyonrailsworks/4153287 to your computer and use it in GitHub Desktop.
Save rubyonrailsworks/4153287 to your computer and use it in GitHub Desktop.
MYSQL
SELECT `tid`, DATE_ADD(`send_goods_at`, INTERVAL 8 HOUR) FROM `taobao_orders` WHERE `tid` IN ('166766380536047', '166789906978402')
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment