Windows Server 2012中,MS SQL Server的选择公司2的值,公司1的值,如果不
我知道有一个基于集合的方式来做到这一点,但我无法弄清楚如何简洁的短语我问题得到一个有用的谷歌答案。
tblConfig
companyid var val
---------------------------------------------------------
1 fruit orange
1 game Monopoly
1 book Joyland
1 actor Ernest Thesiger
1 condiment ketchup
2 fruit apple
2 book Revival
3 actor Colin Clive
3 condiment relish
3 fruit kiwi
3 book Tales From a Buick8
我想选择公司2的值(或3或4或N ...),加上公司1的值,其中2没有一个(顺序不物质),如:
2 fruit apple
1 game Monopoly
2 book Revival
1 actor Ernest Thesiger
1 condiment ketchup
我已经看了this answer,以为我可以使它工作,但它躲开我。我最后列出了表中所有值的列表。