postgis数据库,找出两个表同一字段有字段值有不一致的数据,然后找出的数据需要是唯一值

WITH combined_data AS (
    SELECT *
        FROM {standard_table_my}
        WHERE {map_y} > 0 AND {fieldname_my} IN 
              (SELECT {fieldname_my} 
              FROM {standard_table_my} 
              GROUP BY {fieldname_my} 
              HAVING COUNT(*) = 1)
    )
    SELECT *
         FROM combined_data  s
         LEFT JOIN {standard_table} e ON s.{fieldname_my}  = e.{fieldname} 
         WHERE e.{fieldname}  IS NULL OR s.{fieldname_my}  IS NULL OR s.{fieldname_my}  <> e.{fieldname} 
    '''.format(fieldname_my=fieldname_my,map_y=fieldname_lat,standard_table_my=standard_table_my,standard_table=standard_table,fieldname=fieldname)
    

你可能感兴趣的:(MySQL,postgresq,MongoDB,Redis,postgis)