我有兩個表名爲booked_flat
和master_flat
。的booked_flats
如何在sql中合併兩個不同列的表格
列
customer_name, customer_address, customer_phone, building_wing_no, building_name_no, flat_no
的master_flats
列
當任平獲取預訂的狀態得到改變爲其他出售狀態仍然流拍。
銷售狀態的所有條目都在booking_flats中。
我曾試圖合併這兩表,但它給出了一個錯誤,請幫我
$sql = SELECT * FROM 'booked_flats'
UNION SELECT * FROM 'master_flats'
WHERE building_wing_no, building_name_no, flat_no NOT IN (
SELECT building_wing_no, building_name_no, flat_no from booked_flats);
例如:
**master_flat:**
building_wing_no building_name_no flat_no status
-----------------------------------------------
a a2 104 unsold
-------------------------------------------------
b a3 105 sold
booked_flat:
custo_name custo_add custo_ph building_wing_no building_name_no flat_no
---------------------------------------------------------------------------
harish wardha 284632 b a3 105
I want result like
cust_name cust_add custo_ph building_wing_no building_name_no flat_no status
harish wardha 284632 b a3 105
--- --- --- a a2 104 unsold
這很難回答這樣的問題。請分享一些示例數據以及您試圖獲取該示例的結果。 – Mureinik