多表联合查询

2024-04-24  本文已影响0人  茶饭不思

多表查询筛选性别男 学历XX以上,年龄在XX以上

SELECT id, name, mobile
FROM (
    SELECT id, name, mobile
    FROM fa_miniform_ypzbmjf
    WHERE sex = 1
    AND xueli <= 5
    AND TIMESTAMPDIFF(YEAR, birthday, CURDATE()) < 35

    UNION

    SELECT id, name, mobile
    FROM fa_miniform_fangxunqx
    WHERE sex = 1
    AND xueli <= 5
    AND TIMESTAMPDIFF(YEAR, birthday, CURDATE()) < 35

    UNION

    SELECT id, name, mobile
    FROM fa_miniform_yjglxgy
    WHERE sex = 1
    AND xueli <= 5
    AND TIMESTAMPDIFF(YEAR, birthday, CURDATE()) < 35

) AS combined_results
GROUP BY mobile;
上一篇下一篇

猜你喜欢

热点阅读