全外连接SQL错误jj

时间:2017-09-28 13:35:23

标签: mysql sql

考虑:

Select Dash_Bill_ID As 'رقم الفاتورة',
       c2.Customer_Name As 'العميل',
       c1.Customer_Name As 'المهندس/المقاول',
       delegate.Delegate_Name As 'المندوب',
       Total_CostBD As 'الاجمالي قبل الخصم',
       Total_CostAD As 'الاجمالي بعد الخصم',
       Bill_Date As 'التاريخ',
       Type_Buy As 'طريقة الدفع',
       Initial_Value As 'العربون',
       bank.Bank_Name As 'الخزنة'
From   customer_bill
Full Outer Join customer As c1
    On c1.Customer_ID = customer_bill.Customer_ID
Full Outer Join customer As c2
    On c2.Customer_ID = customer_bill.Client_ID
Full Outer Join delegate
    On delegate.Delegate_ID = customer_bill.Delegate_ID
Full Outer Join bank
    On bank.Bank_ID = customer_bill.Bank_ID
Where  Dash_Bill_ID = 24;

我收到错误:

  

[Err] 1064 - 您的SQL语法有错误;检查与您的MySQL服务器版本对应的手册,以获得正确的语法,以便在c1.Customer_ID = customer_bill.Customer_ID full outer'上使用附近的外部联接客户作为c1。在第1行

1 个答案:

答案 0 :(得分:1)

MySQL不支持FULL JOIN,这是您遇到的具体问题。

但是,甚至不太可能需要FULL JOIN。在构建良好的数据库中,几乎不需要完全连接。假设NULL中所有引用的字段都不是customer_billINNER JOIN应该没问题。或者,您可能需要LEFT JOIN