我在我的项目中使用了两个表格。两张表都在图中显示。项目是在2005年VB.net和SQL Server 2005vb.net中group by子句有问题
这里是我的代码:
SELECT
NorthGangotri.DName, NorthGangotri.DLName, NorthGangotri.Place,
NorthGangotri.add1 , donor_family_detail.*
FROM
NorthGangotri, donor_family_detail
WHERE
NorthGangotri.NGCode = donor_family_detail.NGCode
GROUP BY
donor_family_detail.NGCode
但是当我尝试执行它给出以下错误
任何人都可以请帮助我。
SELECT DISTINCT NorthGangotri.DName, NorthGangotri.DLName, NorthGangotri.Place,
NorthGangotri.add1 , donor_family_detail.*
FROM NorthGangotri
INNER JOIN donor_family_detail on NorthGangotri.NGCode = donor_family_detail.NGCode
也应该使用join
两个表连接:
'GROUP BY donor_family_detail.NGCode'将为每个不同的'NGCode'值生成* 1 *行 - 但可以从* multiple *行派生,每个行对于DName,DLName,Place都有不同的值'等等。服务器不知道为其他列选择什么值。 –
[踢坏的习惯:使用旧式JOIN](http://sqlblog.com/blogs/aaron_bertrand/archive/2009/10/08/bad-habits-to-kick-using-old-style-joins。 aspx) - 老式*逗号分隔的表*样式列表已停止使用ANSI - ** 92 ** SQL标准(**超过20年**前) –