谁能把下面的句子改成tquery能支持的sql?(我用的是.db表)
update table1 set sums=(SELECT SUM(table2.Pxx*table2.Pyx) AS Expr1
FROM table1 INNER JOIN table2
ON table1.word = table2.S1 OR table1.word = table2.S2
GROUP BY table1.word
)
这个句子是标准的sql语句,在sql server下大概能通过,但在Delphi的query中使用,总报错:single row subquery produced more than one row
update table1 set sums=(SELECT SUM(table2.Pxx*table2.Pyx) AS Expr1
FROM table1 INNER JOIN table2
ON table1.word = table2.S1 OR table1.word = table2.S2
GROUP BY table1.word
)
这个句子是标准的sql语句,在sql server下大概能通过,但在Delphi的query中使用,总报错:single row subquery produced more than one row
FROM table1,table2
WHERE (table1.word = table2.S1 OR table1.word = table2.S2 )
GROUP BY table1.word
试试看
使用set的时候只能是一对一
楼上这方法也不行啊,加上这个首先top 1 是什么呢?1那报错了,不认,去掉1后,后面那个select 有不对了,怎么回事啊
需要限制SUM(table2.Pxx*table2.Pyx)输出一个记录
你的子查询里的where语句限制不够
你可以在查询分析器里调试一下看是什么情况
采用更加严格的限制条件
FROM table1 INNER JOIN table2
ON table1.word = table2.S1GROUP BY table1.word union select SELECT SUM(table2.Pxx*table2.Pyx) AS Expr1 FROM table1 INNER JOIN table2
table1.word = table2.S2
GROUP BY table1.word
)
按楼主的要求,一旦代码中出现GROUP BY至少可以说明该代码不够精练是主从表需要更新主表么?
UPDATE fxy11
SET sums=(select sums from temp
WHERE fxy11.word = temp.Ss)