通过在postgres中比较它们来删除数据库中的重复记录

时间:2015-10-09 10:24:43

标签: sql postgresql

我有两张桌子。

  • friend class std::allocator<A>;

    table1
  • i_r_p | prod_id | dest_id | is_disabled ----------------------+------------+----------------+------------- 1 | 11 | 2004 | f 2 | 12 | 5112 | f 3 | 11 | 1403 | f 4 | 12 | 5112 | f 5 | 11 | 2944 | f

    table2

待办事项:

我想删除 i_r_p_v | i_r_p_id | ven_id | preference ---------+----------+-----------+------------ 1 | 1 | 101 | 190 2 | 1 | 101 | 250 3 | 2 | 101 | 500 4 | 4 | 318 | 125 5 | 4 | 318 | 225 6 | 3 | 127 | 50 中具有相同table1的条目。 我想删除prod_id AND dest_id中具有相同table2

的条目

我的工作:

(i_r_p_id AND ven_id) AND preference > 100 AND if entries have same preferences then delete any entry, else delete records with less than the highest preference found.

由于某些原因,我无法直接在数据库上运行删除命令,而且我无法提取我必须删除的确切数据。

0 个答案:

没有答案