Update Query with Correlated Subquery

后端 未结 2 1732
日久生厌
日久生厌 2021-01-23 07:51

I\'m trying to convert a Foxpro application into .NET. As part of that conversion I\'m converting the data from DBF tables to Sql server.

I need to come up with a coupl

2条回答
  •  南笙
    南笙 (楼主)
    2021-01-23 08:16

    Try this

    UPDATE customers
    SET FirstOrderDate = 
    (Select MIN(OrderDate)
    FROM Orders
    WHERE ShipperId = Customers.Id or
    PickupId = Customers.Id or
    ConsigneeId = Customers.Id or
    DeliveryId = Customers.Id or
    BillingId = Customers.Id)
    

提交回复
热议问题