Created
June 20, 2014 16:04
-
-
Save archsh/5e5d2d56283120b720b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* A SQL get all rows with duplicated values in cols*/ | |
/*从一个表里面查询出一个或多个字段含有同样值的SQL语句。*/ | |
SELECT orders.* FROM risingstardb2.sales_order AS orders | |
LEFT JOIN ( SELECT group_concat(ids) AS ids FROM | |
(SELECT COUNT(*) AS num, group_concat(id) as ids | |
FROM risingstardb2.sales_order GROUP BY consignee_name, consignee_phone, delivery_address | |
HAVING COUNT(*) > 1 ) AS new_orders) AS order_ids | |
ON TRUE WHERE FIND_IN_SET(orders.id, order_ids.ids); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment