473,398 Members | 2,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Need help designing an update query

I'd like to have a way to add bidders who have won at least $1000 in
the last auction to my mailing list. I'm having trouble with the
update step.

To find bidders who have won at least $1000 in the last auction, I
created this query:

SELECT Sum(Lots.HighBidAmount) AS SumOfHighBidAmount,
Lots.HighBidderNumber
FROM Lots, [Active auctions]
GROUP BY Lots.HighBidderNumber, Lots.AuctionID
HAVING (((Sum(Lots.HighBidAmount))>=1000) AND
((Lots.AuctionID)=First([Active auctions].[AuctionID])));

[Active auctions] is a query that returns a single row identifying the
active auction. The above query, which I named "Bidders winning $1000
minimum" appears to return the correct results.

Next, I figured I'd use the bidder numbers identified in the above
query to select the bidder records to have the mail flag set. I tried
this:

UPDATE [Bidders winning $1000 minimum]
INNER JOIN Bidders
ON [Bidders winning $1000 minimum].HighBidderNumber = Bidders.BidderID
SET Bidders.MailFlag = -1;

I get this error: "Operation must use an updateable query."

I also tried phrasing it the other way around:

UPDATE Bidders
INNER JOIN [Bidders winning $1000 minimum]
ON Bidders.BidderID = [Bidders winning $1000 minimum].HighBidderNumber
SET Bidders.MailFlag = -1;

No luck. I also tried LEFT and RIGHT JOINs, to no avail.

Can someone point me in the right direction?
Thanks
tbone
Jan 21 '06 #1
3 1293
tbone wrote:
I'd like to have a way to add bidders who have won at least $1000 in
the last auction to my mailing list. I'm having trouble with the
update step.

To find bidders who have won at least $1000 in the last auction, I
created this query:

SELECT Sum(Lots.HighBidAmount) AS SumOfHighBidAmount,
Lots.HighBidderNumber
FROM Lots, [Active auctions]
GROUP BY Lots.HighBidderNumber, Lots.AuctionID
HAVING (((Sum(Lots.HighBidAmount))>=1000) AND
((Lots.AuctionID)=First([Active auctions].[AuctionID])));

[Active auctions] is a query that returns a single row identifying the
active auction. The above query, which I named "Bidders winning $1000
minimum" appears to return the correct results.

Next, I figured I'd use the bidder numbers identified in the above
query to select the bidder records to have the mail flag set. I tried
this:

UPDATE [Bidders winning $1000 minimum]
INNER JOIN Bidders
ON [Bidders winning $1000 minimum].HighBidderNumber = Bidders.BidderID
SET Bidders.MailFlag = -1;

I get this error: "Operation must use an updateable query."

I also tried phrasing it the other way around:

UPDATE Bidders
INNER JOIN [Bidders winning $1000 minimum]
ON Bidders.BidderID = [Bidders winning $1000 minimum].HighBidderNumber
SET Bidders.MailFlag = -1;

No luck. I also tried LEFT and RIGHT JOINs, to no avail.

Can someone point me in the right direction?
Thanks
tbone


Can use use something else besides a Totals query? If you use a Totals
query, it is not updateable. Perhaps use Dsum()?
Jan 21 '06 #2

update bidders
set mailFlag = -1
where bidderId in (select highBidderNumber FROM [Bidders winning $1000
minimum]);

should work
tbone wrote:
I'd like to have a way to add bidders who have won at least $1000 in
the last auction to my mailing list. I'm having trouble with the
update step.

To find bidders who have won at least $1000 in the last auction, I
created this query:

SELECT Sum(Lots.HighBidAmount) AS SumOfHighBidAmount,
Lots.HighBidderNumber
FROM Lots, [Active auctions]
GROUP BY Lots.HighBidderNumber, Lots.AuctionID
HAVING (((Sum(Lots.HighBidAmount))>=1000) AND
((Lots.AuctionID)=First([Active auctions].[AuctionID])));

[Active auctions] is a query that returns a single row identifying the
active auction. The above query, which I named "Bidders winning $1000
minimum" appears to return the correct results.

Next, I figured I'd use the bidder numbers identified in the above
query to select the bidder records to have the mail flag set. I tried
this:

UPDATE [Bidders winning $1000 minimum]
INNER JOIN Bidders
ON [Bidders winning $1000 minimum].HighBidderNumber = Bidders.BidderID
SET Bidders.MailFlag = -1;

I get this error: "Operation must use an updateable query."

I also tried phrasing it the other way around:

UPDATE Bidders
INNER JOIN [Bidders winning $1000 minimum]
ON Bidders.BidderID = [Bidders winning $1000 minimum].HighBidderNumber
SET Bidders.MailFlag = -1;

No luck. I also tried LEFT and RIGHT JOINs, to no avail.

Can someone point me in the right direction?
Thanks
tbone


Jan 23 '06 #3
Excellent! Works perfectly!

I did not know a SELECT could be used withing a WHERE clause.

Thanks for that valuable lesson!

tbone
On 23 Jan 2006 04:05:54 -0800, le*********@natpro.com wrote:

update bidders
set mailFlag = -1
where bidderId in (select highBidderNumber FROM [Bidders winning $1000
minimum]);

Jan 23 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: http://ray1.net/ | last post by:
Dear Readers. Using Javascript in ASP I need a way of returning through ADO (connection or recordset) the message returned via SQL when I run a query that UPDATES, DELETES or an SP that returns...
9
by: netpurpose | last post by:
I need to extract data from this table to find the lowest prices of each product as of today. The product will be listed/grouped by the name only, discarding the product code - I use...
1
by: Jimmy Tran | last post by:
Hi All, I have a table below and I want to design a query to pull all the members from the TABLE into a Query Result and into a single column with points assigned appropriately, but I am having...
2
by: Jackson Yap | last post by:
can someone kind enough to help me look at the attached html and js file? Why is it that the javascript menu could not work at www.apchosting.net but could work at...
2
by: sk | last post by:
I have a table for storing alerts (exceptional situations) occuring on devices that I monitor. Associated with each alert is an alert code, a description, the device responsible for causing the...
2
by: Sky Sigal | last post by:
Hello: I'm currently messing around, and need as much feedback/help as I can get, trying to find the most economical/graceful way to build usercontrols that rely on styling to look any good... ...
3
by: Larry Woods | last post by:
I have a datagrid that is carrying all fields of a record...except one. Now I want to update the underlying database via a dataadapter. The update is working but the field that is "left out" is...
2
by: bobabooey2k | last post by:
I have an update query with one field having in its "Update to" cell a DLookup statement. This query takes 2-3 minutes on 3000 records. Can I avoid dlookup here using multiple queries? An...
9
by: Tony Girgenti | last post by:
Hello I developed and tested a web application using VS.NET 2003, VB, .NET Framework 1.1.4322, ASP.NET 1.1.4322 and IIS5.1. It uses a web form. I tried doing this without any help, but i'm...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.