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

Problem with update query

I am trying to run an update query and am having problems with null
values.

Starting from the beginning - I created a new table from my original
table, selecting distinct combinations of these rows:

Family, Genus, Species, Variety, Author

I then added an ID field to uniquely identify each of these rows.
Sample of data that may be in these rows:

taxa_id: 1
Family: Aceraceae
Genus: Acer
Species: circinatum
Variety: (is null)
Author: (is null)

The records vary as to how much information is in them. They may have
all of these fields, or only Family and Genus.

Now I would like to go back to my original table and assign this new
ID number to the corresponding record. I created a new field in the
original table, called taxa_id and am trying to run an update query to
fill in the new ID number:

"UPDATE table1, taxa SET table1.taxa_id = taxa.taxa_id
WHERE (((table1.Family)=[taxa].[family])
AND ((table1.Genus)=[taxa].[genus])
AND ((table1.Species)=[taxa].[species])
AND ((table1.Var)=[taxa].[var])
AND ((table1.Author)=[taxa].[author]));"

The problem is that it is only picking up 24 out of 2626 rows, because
it is not picking up any rows that have a null value in any of the
fields. Why would this be? I should be able to compare a Null to a
Null, right?

Thanks,
D.
Nov 12 '05 #1
2 2572
On 30 Nov 2003 17:34:21 -0800, d_*******@hotmail.com (D Newsham)
wrote:

No, you shouldn't. NULL <> NULL. All the books say so.

I would go back to the original table and run that Distinct query
again. If that's not an option, perhaps the Nz function may help:
WHERE (((Nz(table1.Family))=Nz([taxa].[family]) ) 'etc.

-Tom.

I am trying to run an update query and am having problems with null
values.

Starting from the beginning - I created a new table from my original
table, selecting distinct combinations of these rows:

Family, Genus, Species, Variety, Author

I then added an ID field to uniquely identify each of these rows.
Sample of data that may be in these rows:

taxa_id: 1
Family: Aceraceae
Genus: Acer
Species: circinatum
Variety: (is null)
Author: (is null)

The records vary as to how much information is in them. They may have
all of these fields, or only Family and Genus.

Now I would like to go back to my original table and assign this new
ID number to the corresponding record. I created a new field in the
original table, called taxa_id and am trying to run an update query to
fill in the new ID number:

"UPDATE table1, taxa SET table1.taxa_id = taxa.taxa_id
WHERE (((table1.Family)=[taxa].[family])
AND ((table1.Genus)=[taxa].[genus])
AND ((table1.Species)=[taxa].[species])
AND ((table1.Var)=[taxa].[var])
AND ((table1.Author)=[taxa].[author]));"

The problem is that it is only picking up 24 out of 2626 rows, because
it is not picking up any rows that have a null value in any of the
fields. Why would this be? I should be able to compare a Null to a
Null, right?

Thanks,
D.


Nov 12 '05 #2
TC
If you want to compare two fields A and B, where either or both might be
null, but you want them to match if >both< are null, use this:

((A IS NULL AND B IS NULL) OR (A=B))
HTH,
TC
"D Newsham" <d_*******@hotmail.com> wrote in message
news:c8**************************@posting.google.c om...
I am trying to run an update query and am having problems with null
values.

Starting from the beginning - I created a new table from my original
table, selecting distinct combinations of these rows:

Family, Genus, Species, Variety, Author

I then added an ID field to uniquely identify each of these rows.
Sample of data that may be in these rows:

taxa_id: 1
Family: Aceraceae
Genus: Acer
Species: circinatum
Variety: (is null)
Author: (is null)

The records vary as to how much information is in them. They may have
all of these fields, or only Family and Genus.

Now I would like to go back to my original table and assign this new
ID number to the corresponding record. I created a new field in the
original table, called taxa_id and am trying to run an update query to
fill in the new ID number:

"UPDATE table1, taxa SET table1.taxa_id = taxa.taxa_id
WHERE (((table1.Family)=[taxa].[family])
AND ((table1.Genus)=[taxa].[genus])
AND ((table1.Species)=[taxa].[species])
AND ((table1.Var)=[taxa].[var])
AND ((table1.Author)=[taxa].[author]));"

The problem is that it is only picking up 24 out of 2626 rows, because
it is not picking up any rows that have a null value in any of the
fields. Why would this be? I should be able to compare a Null to a
Null, right?

Thanks,
D.

Nov 12 '05 #3

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

Similar topics

3
by: Kulnor | last post by:
My hosting company upgraded yesterday to pHp 4.3.10. Since then, all my INSERT/UPDATE/DELET query on our MS-SQL database seem to fail. No specific error message is returned by...
3
by: rrh | last post by:
I am trying to update a field in one table with data from another table. The problem I'm running into is I need to base the update on a range of data in the 2nd table. Table 1 has: date field...
4
by: John Baker | last post by:
Hi: I have two tables, a setup table (TblSetup) and a purchase order table (tblPO). When i construct a query with ONLY the tblPO shown, and a type in parameter for the PO number, I an update...
6
by: John Baker | last post by:
Hi: As those who have looked at this newsgroup recently will realize, I am a neophyte with Access, although I have experienced with Approach (the Lotus product). There are things I could easily...
7
by: Patrick Fisher | last post by:
Hi I have a table which Contains entries with RefCode field containing INVP or INVPD Common fields in each entry would be InvoiceNo, Total and PurTyp for example. You could have ...
31
by: Lag | last post by:
Having a problem updating my database from a web page, through a submission form. Can anyone help? ----THIS IS MY CODE IN update.php----(user, pass, and database are typed in directly, I...
3
by: Juan Antonio Villa | last post by:
Hello, I'm having a problem replicating a simple database using the binary log replication, here is the problem: When the master sends an update to the slave, an example update reads as follows:...
15
by: sara | last post by:
I have a Memo field in a table to hold notes from a conversation a social worker has had with a client (this is for a non-profit). If the user needs to update the memo field, I need to find the...
4
by: raghuvendra | last post by:
Hi I have a jsp page with 4 columns: namely Category name , Category order, Input field and a submit button. All these are aligned in a row. And Each Category Name has its corresponding Category...
1
by: giovannino | last post by:
Dear all, I did a query which update a sequence number (column NR_SEQUENZA) in a table using a nice code (from Trevor !). 1) Given that I'm not a programmer I can't understand why...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.