table join with a sum works in sql 
Author Message
 table join with a sum works in sql

here is an oracle statement converted for access
UPDATE table1 SET col2 = (SELECT col2 FROM table2
WHERE table1.col1 = table2.col1 AND table1.col3 = table2.col3);
CONVERTED TO
strSQl = "UPDATE table1 LEFT JOIN table2 " & _
         "ON table1.col1 = table2.col1 " & _
         "SET table1.col2 = table2.col2;"

I do not know how to work the group function
sum into access

this oracle sql statement
 UPDATE TABLE1 SET COL3 =
 (SELECT SUM(TABLE2.COL3) FROM TABLE2
  WHERE TABLE1.COL1 = TABLE2.COL1);
needs to be usable in access



Sun, 13 Jul 2003 04:50:12 GMT  
 table join with a sum works in sql
Hi,

Jet doesn't like aggregate in updateable query.  Use a temp table or, if
within the combo JET+ACCESS:

UPDATE table1  SET col3= DSum("col2", "table2", "col1=" & Table1.Col1)

If it was not of the SUM, you could have write a JOIN rather than a
sub-select statement, and Jet will have agree to update ( I use your Oracle
statement, dropping SUM around table2.col3, then, in Jet, it would have be):

UPDATE table1 INNER JOIN table2
    ON table1.col1=table2.col1
SET table1.col3=  table2.col3

Generally, Jet prefers JOIN over WHERE clause involving two tables  (as long
as updateability is concerned).

Hoping it may help,
Vanderghast, Access MVP


Quote:
> here is an oracle statement converted for access
> UPDATE table1 SET col2 = (SELECT col2 FROM table2
> WHERE table1.col1 = table2.col1 AND table1.col3 = table2.col3);
> CONVERTED TO
> strSQl = "UPDATE table1 LEFT JOIN table2 " & _
>          "ON table1.col1 = table2.col1 " & _
>          "SET table1.col2 = table2.col2;"

> I do not know how to work the group function
> sum into access

> this oracle sql statement
>  UPDATE TABLE1 SET COL3 =
>  (SELECT SUM(TABLE2.COL3) FROM TABLE2
>   WHERE TABLE1.COL1 = TABLE2.COL1);
> needs to be usable in access



Sun, 13 Jul 2003 21:13:04 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Need help with joined table sum query

2. SQL - Join one table in one destination to another table in another destination (DBF)

3. ttx, joining 2 tables does not work

4. Acc20: Working Querydef's SQL Property Yields Unsupported Join Expression

5. HELP: SQL LEFT JOIN not working

6. My Join Doesn't work - sql against cdb database

7. SQL JOIN and tables not updatetable

8. Join 2 tables which protected with password using SQL

9. SQL: Non-Equal Join of Two Tables

10. Delete Query on Joined Tables on SQL Server

11. SQL problem: Joining tables in different dbases

12. SQL: Non-Equal Join of Two Tables

 

 
Powered by phpBB® Forum Software