SQL 使用inner join联合查询两张表


使用inner join联合查询两张表,查询每张表时都可以加单独的where条件:

select
    tabel1.id,
    tabel1.name,
    tabel2.address,
from
    (
        select
            id,
            name,
            age
        from
            id_name_age_table
        where
            age < 50
    ) as tabel1
    inner join (
        select
            id,
            address,
            income
        from
            id_address_income_table
        where
            income > 10000
    ) as tabel2 on tabel1.id = tabel2.id

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM