如何查看来自不同表的数据

时间:2015-05-27 05:06:01

标签: sql postgresql

我有4张桌子:$( "ul.my_sortable" ).sortable({ ... start: function (event, ui) { // get placeholder position when selecting item place_prev = ui.placeholder.prev(); start_col = $(this); target_col = $(this) }, change: function (event, ui) { // keep track of where the placeholder moves... place_pos = ui.placeholder.index(); // and reset it back to its starting position so it doesn't appear to move place_prev.after(ui.placeholder); }, beforeStop: function (event, ui) { // move the choice to the correct column when you let go if (!target_col.is(start_col)) { target_col.append(ui.item); } } });

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 时如何查看"fname,lname,status,total"的值 因为ORNo = '875'归同一所有者所有。

1 个答案:

答案 0 :(得分:3)

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'