Re: Update table with SQL
- From: "John Spencer" <spencer@xxxxxxxxx>
- Date: Tue, 22 Aug 2006 08:56:47 -0400
How about using the DCount function? Access won't allow you to use
aggregate queries in an update query (other than in a where clause).
UPDATE TABLE1
SET Table1.Column1 =DCount("*","Table2","Column2 = 2")
"Allen Browne" <AllenBrowne@xxxxxxxxxxxxxx> wrote in message
news:e8xj3hcxGHA.560@xxxxxxxxxxxxxxxxxxxxxxx
Access will interpret the quotes as a literal string, so the where clause
of the query is comparing a literal string to a number.
Perhaps you want something like this:
update TABLE1 set Column1 =
(select count(*)
from TABLE2
where (Table2.Column2 = Table1.Column2));
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Roger Svensson" <roger.svensson@xxxxxxxxxxxxx> wrote in message
news:%23koZ3AcxGHA.4876@xxxxxxxxxxxxxxxxxxxxxxx
I have a SQL query that works fine on an SQL server database but not on
an
equivalent Access database. Can anyone please help me tune the query to
function in Access?
The query looks like this:
update TABLE1 set Column1 = (select count(*) from TABLE2
where("Column2"=2))
.
- Follow-Ups:
- Re: Update table with SQL
- From: Roger Svensson
- Re: Update table with SQL
- References:
- Update table with SQL
- From: Roger Svensson
- Re: Update table with SQL
- From: Allen Browne
- Update table with SQL
- Prev by Date: Re: Rounding to nearest 1000
- Next by Date: Re: Rounding to nearest 1000
- Previous by thread: Re: Update table with SQL
- Next by thread: Re: Update table with SQL
- Index(es):
Relevant Pages
|