欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

access 的多个left join 要加括号

程序员文章站 2022-06-02 19:36:18
...

string sql = "select a.orderId,a.UserName,b.CodeValue as Delivery ,a.DeliveryAddress,a.PhoneNum,c.CodeValue as Payment,d.CodeValue as OrderStatus,d.CodeValue as OrderStatusID,a.OrderTime,a.Merchant from (( m_Order a "; sql += " left join (

string sql = "select a.orderId,a.UserName,b.CodeValue as Delivery ,a.DeliveryAddress,a.PhoneNum,c.CodeValue as Payment,d.CodeValue as OrderStatus,d.CodeValue as OrderStatusID,a.OrderTime,a.Merchant from (( m_Order a ";

sql += " left join ( select CodeId,CodeValue from M_DefaultValue where TableId='Delivery') as b on a.Delivery =b.CodeId )";

sql += " left join ( select CodeId,CodeValue from M_DefaultValue where TableId='Payment') as c on a.Payment=c.CodeId )";

sql += " left join ( select CodeId,CodeValue from M_DefaultValue where TableId='OrderStatu') as d on a.OrderStatus =d.CodeId ";

标记一下