gpt4 book ai didi

sql - 如何查看不同表的数据

转载 作者:行者123 更新时间:2023-11-29 12:44:44 25 4
gpt4 key购买 nike

我有 4 个表:tbl_info、tbl_owner、tbl_accounts、tbl_billing

--tbl_info: information
info_id | fname | lname
10 | ron | lum

--tbl_owner: owner
own_id | owner_info_id |property_type
01 | 10 | land

--tbl_all_property: landfindings
property_id | property_owner_id | owner_id | OR_no
1 | 101 | 10 | 987
2 | 101 | 10 | 874
3 | 101 | 10 | 875

--tbl_billing: billing
bill_id | status | total | property_id
1 | not paid | 100 | 1

我的问题是当我输入 ORNo = '875' 时如何查看 "fname,lname,status,total" 的值因为 3 OR_no 归同一所有者所有。

最佳答案

select a.fname,
a.lname,
d.status,
d.total
from tbl_info a
inner join tbl_owner b
on a.info_id=b.owner_info_id
inner join tbl_all_property c
on c.owner_id=b.owner_info_id
inner join tbl_billing d
on d.property_id=c.property_id
where c.OR_no='875'

关于sql - 如何查看不同表的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30473604/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com