Can I use CASE statement in a JOIN condition?

前端 未结 9 1955
庸人自扰
庸人自扰 2020-11-22 09:32

The following image is a part of Microsoft SQL Server 2008 R2 System Views. From the image we can see that the relationship between sys.partitions and sys

9条回答
  •  温柔的废话
    2020-11-22 09:47

    This seems nice

    https://bytes.com/topic/sql-server/answers/881862-joining-different-tables-based-condition

    FROM YourMainTable
    LEFT JOIN AirportCity DepCity ON @TravelType = 'A' and DepFrom =  DepCity.Code
    LEFT JOIN AirportCity DepCity ON @TravelType = 'B' and SomeOtherColumn = SomeOtherColumnFromSomeOtherTable
    

提交回复
热议问题