MySQL多表联合查询过滤重复数据怎么写
发布网友
发布时间:2022-04-28 15:00
我来回答
共2个回答
热心网友
时间:2022-05-02 06:42
复审表通过一次自连接筛选出最大值后再做关联
SELECT
花名册.工号,
花名册.姓名,
取证情况.证书信息,
复审情况F.复审时间
FROM
花名册
LEFT JOIN 取证情况 ON 花名册.工号 = 取证情况.工号
LEFT JOIN (
SELECT 复审情况.* FROM 复审情况
INNER JOIN
(SELECT MAX(复审时间) 复审时间,工号 FROM 复审情况 GROUP BY 工号) 复审情况2
ON 复审情况.复审时间=复审情况2.复审时间 AND 复审情况.工号=复审情况2.工号
) 复审情况F ON 花名册.工号 = 复审情况F.工号;
热心网友
时间:2022-05-02 08:00
MySQL多表联合查询过滤重复数据怎么写
SELECT COUNT(DISTINCT <a href="https://www.baidu.com/s?wd=AA&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1Y3rjNWuWbzm19Wm1DzrADY0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnH61nH0knW0Yn1RYn1cdPj6zn0" target="_blank" class="-highlight">AA</a>.字段)
FROM (SELECT 字段
FROM TABLE1
UNION ALL
SELECT 字段 FROM TABLE2) <a href="https://www.baidu.com/s?wd=AA&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1Y3rjNWuWbzm19Wm1DzrADY0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnH61nH0knW0Yn1RYn1cdPj6zn0" target="_blank" class="-highlight">AA</a>;