你能帮我写一个有效的sql查询吗?
我需要选择所有重复的link_rewrite。仅当 id_shop、id_lang 相同时才重复。
查看完整代码:https ://github.com/Ha99y/prestashopCleanURLs/blob/master/PS15/cleanurls.php#L49
-------------------------------------------------------
| id_product | id_shop | id_lang | link_rewrite |
-------------------------------------------------------
| 1 | 1 | 1 | ipod-nano |
| 1 | 1 | 2 | ipod-nano |
| 2 | 1 | 1 | ipod-nano |
| 2 | 1 | 2 | ipod-nano |
| 8 | 2 | 1 | ipod-nano |
| 8 | 2 | 2 | ipod-nano |
-------------------------------------------------------
SQL:
SELECT * FROM `ps_product_lang`
WHERE `link_rewrite`
IN (SELECT `link_rewrite` FROM `ps_product_lang`
GROUP BY `link_rewrite`, `id_lang`
HAVING count(`link_rewrite`) > 1)
.
任何帮助表示赞赏