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