473,320 Members | 1,933 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,320 software developers and data experts.

Need help with subquery that does an update.

167 100+
Here is currently what I have coded:
Expand|Select|Wrap|Line Numbers
  1. Update HWInv set ReconFAS = True, DateFAS = Date() 
  2. where exists
  3. (SELECT asset_number
  4. FROM tbl_FASRecon
  5. WHERE Verified_By = "IT Recon" )
My problem is that when I run the select statement by itself it returns 5821 rows. Then, I put the "Update" in front of it and it updates 6323 rows. The 5821 rows is actually what should be updated. I can't figure out what I have wrong. Basically, I want to update the HWInv table only if the asset_number exists in the tlb_FASRecon and has been verified (Verified_By = "IT Recon". Any suggestions would be appreciated!!
Dec 9 '10 #1
3 1534
NeoPa
32,556 Expert Mod 16PB
I don't see what you expect to happen here. There are two distinct tables involved and no way to link the two. tbl_FASRecon.Asset_Number is clearly meant to be associated with something from [HWInv], but I see nothing that would say so.
Dec 13 '10 #2
ncsthbell
167 100+
Oops.... I left the join off. I changed it to add a join for on the asset number from both tables and I got 2rows, should get over 5000. Here is the code changed:
Expand|Select|Wrap|Line Numbers
  1. Update HWInv set ReconFAS = True, DateFAS = Date()
  2. where exists
  3. (SELECT asset_number
  4. FROM tbl_FASRecon
  5. WHERE Verified_By = "IT Recon"
  6. and HWInventory.DORAssetTag = tbl_FASRecon.asset_number );
Dec 14 '10 #3
NeoPa
32,556 Expert Mod 16PB
Ooops. Still no JOIN. The extra WHERE expression introduces a new table, hitherto unseen, into the equation.

Perhaps you rushed the posting again, without taking adequate care with the details? I imagine you don't yet appreciate how important such care is when developing, but hopefully this will be a pointer for you ;-)
Dec 15 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: marcello stanley | last post by:
--Boundary_(ID_89yLhNmAybJBOhP/kmhVvw) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7BIT Hello, I am a mySQL newbie here and have some problem defining the mySQL...
2
by: coryjflynn | last post by:
I am try to update the Gender field for all females of a database with about 15,000 records. So how I started was by searching baby girl names on the web and manipulated some of there lists to...
7
by: Andrew Mayo | last post by:
Here's a really weird one for any SQL Server gurus out there... We have observed (SQL Server 2000) scenarios where a stored procedure which (a) begins a transaction (b) inserts some rows into...
2
by: Edwin Pauli | last post by:
Hi, Yesterday i had upgrade my PostgreSQL server from version 7.2.4 to 7.4.1. There are troubles with a subquery after the upgrade. Here is the query: SELECT team_naam, team_id, wpim, (
19
by: Steve | last post by:
ASP error number 13 - Type mismatch with SELECT...FOR UPDATE statement I got ASP error number 13 when I use the SELECT...FOR UPDATE statement as below. However, if I use SELECT statement without...
0
by: jonathandrott | last post by:
I'm new to using two access (oledb) databases at the same time with my vb program. I have a db named InvoiceProcessing that has two fields UPC and ItemDesc. UPC is populated, but ItemDesc...
2
by: LordGoran | last post by:
I'm stumped with this one. I'm trying to recode an SQL statement written in Access that will work for MySQL (4.1.22). In Access it used a stored Query, I'd like to use a subquery to replace the...
4
by: thatguyNYC | last post by:
Hey there-- I have a form with two listboxes, each populated by SQL statements that pull from separate tables, like this: lstAvail.RowSource = SELECT Person_Id, LastName, FirstName FROM HREmps...
0
by: JB | last post by:
I have an ASP project written years ago that I have recently started to try and update. It was written by someone who used to work here before me, and the source code I have is in a major mess. ...
2
by: Zoopie911 | last post by:
I have a statement that would be valid in Oracle, but SQL Server doesn't like this form. I looked at the FROM clause and still can't figure out how to implement the statement... HELP!! update...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.