1

这将是一个奇怪的请求,有人可以用简单的英语解释下面的查询在做什么,尤其是 <>0 位。

Select S.[Silks_Skey], MC.[MajorColour_Skey], MC.[MajorColour]
from [dbo].[Silks] S 
inner join [dbo].[SubColour] SC on CHARINDEX(SC.[SubColour],S.[SilksName]) <> 0
inner join [dbo].[MajorColour] MC on SC.[MajorColour] = MC.[MajorColour]

谢谢

W

4

2 回答 2

1

The charindex(expressionToFind, expressionToSearch) function searches for the occurance of a string in another string. If the string is not found, it returns 0, otherwise it returns the position of the first string in the second.

inner join [dbo].[SubColour] SC on CHARINDEX(SC.[SubColour],S.[SilksName]) <> 0

So the join looks for all SubColours that are contained in the silk's name. For example, if the silk was called "high-quality blue and green silk", this would join in the blue and green subcolours.

于 2013-05-03T09:23:08.567 回答
1

丝绸名称包含与其相关的子颜色名称。子颜色与主要颜色相关。如果丝绸名称包含子颜色名称,则返回丝绸及其相关的主要颜色。

于 2013-05-03T09:23:30.107 回答