I have an Access 2016 table with several columns, one of which is a column SerialNumberExclude. I want to compare data from another table and if the serial number in this table matches any serial number in the SerialNumberExclude, I want to exclude those records in my query. hope that's not too confusing. I'm only YouTube University qualified with Access! LOL
**Additional info: Serial numbers are a text format and are entered in the column like this: 123, 1234, 345, 3456, etc. There can be multiple serial numbers associated with an item in my table. So if serial number 345 is in my table that I am comparing, I don't want to see it in my query.
8 5089 twinnyfo 3,653
Recognized Expert Moderator Specialist
Soupy,
Welcome to Bytes!
Example: - tblSoupySales
-
SoupyID
-
SoupyName
-
SoupyPlace
-
SerialNumberExclude
- tblSoupySerials
-
SerialNumber
-
SoupyBreakfast
-
SoupyLunch
-
SoupyDinner
Your Query would look something like: - SELECT *
-
FROM tblSoupySales
-
LEFT JOIN tblSoupySerials
-
ON tblSoupySale.SerialNumberExclude = tblSoupySerials.SerialNumber
-
WHERE tblSoupySerials.SerialNumber Is Null;
This should display all records in tblSoupySales that do NOT have a matching record in tblSoupySerials.
Hope this hepps!
Thanks for the reply. I guess I'm not understanding as this is new to me. Can this be done with a Criteria statement in the Access query? Where the query compares the two tables and returns all line items except those where the serial number is a certain number? Sorry for my ignorance on this.
twinnyfo 3,653
Recognized Expert Moderator Specialist
Soupy,
Yes and yes. You can build this query in the Query Designer or simply type it in in the SQL view.
If you are designing the query in the Query Designer, just add your two tables and create a relationship between the two tables. Double click the relationship line to edit it and select "Include all records from tblSoupySales ...." Then drag tblSoupySerials.SerialNumber to the fields list, and add "Is Null" in the criteria section.
This is a very common design. Often, you only want the records that have a matching record in the second table, but it is often helpful to know which records do not have corresponding records.
Again, hope this hepps!
NeoPa 32,557
Recognized Expert Moderator MVP
I hate to rain on anyone's parade here, but if you really mean you are entering multiple serials to exclude into a string value then trying to exclude any and all of those items then this is far more complicated than shown so far.
The short response is to avoid such a design like the plague, but that's another story.
twinnyfo 3,653
Recognized Expert Moderator Specialist
Sio,
Thanks for the discussion. However, OP states:
I want to compare data from another table and if the serial number in this table matches any serial number in the SerialNumberExclude, I want to exclude those records in my query.
Based upon this definition, and based upon the data in your tables above, my query would, indeed, return no records. This is because every record in tblSoupySales has a corresponding record in tblSoupySerial. However, when you change any of the values in the Field SerialNumberExclude to a value that does NOT exist in tblSoupySerials, that record will show up.
I believe this this the result the OP wants, but outside of OP confirming or denying, we must go on mere interpretation of their post.
NeoPa 32,557
Recognized Expert Moderator MVP
I'd just like to repeat here that the best advice we can give to this OP is that they should be approaching this completely differently.
DO NOT use lists within a string and expect a database system to work well with it.
DO NOT use variable-length strings in your PK if it's at all possible to avoid.
They have explained they're new and mistakes are easily made. Unless we, as experts, explain this to them clearly they may go off without that most important understanding.
The EXCEPT operator is used to exclude like rows that are found in one query but not another. It returns rows that are unique to one result. To use the EXCEPT operator, both queries must return the same number of columns and those columns must be of compatible data types.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: 'bonehead |
last post by:
Greetings,
I'd like to figure out some syntax for retrieving the data from a table
when I don't know all the of field names. What I do know are, the name
of the table, the names of the primary...
|
by: Oliver Stratmann |
last post by:
Hello All!
I'm looking for a description of the needs of space for a certain data-type.
How much space does e.g. a NUMERIC(1,0)- field take? (??? Bytes?)
Is there a listing in the...
|
by: MX1 |
last post by:
Here's an interesting one. I have a database that has user level security
invoked. The design is normalized and I have one field in particular called
Rep ID. Any thoughts on how I can allow all...
|
by: Peter |
last post by:
I have a site which uses forms authentication but I would
like to exclude certain pages on the site from
authentication. In other words I would like the user to be
able to get to these pages...
|
by: enambo |
last post by:
In MS Access, i would to give the locking system to certain user, by which they can enable or disable to work on certain data entry or reports.
How can i work on that?
Kartik
| |
by: bmdlfc |
last post by:
Morning all, long time reader, first time poster.
I need to manipulate an existing CSV file and create another one from it but excluding some fields.
For example, the fields I have in the...
|
by: Prodian |
last post by:
Im trying to parse a recv from a telnet session then only grab certain data.
Heres an example of the recv that Im storing into a string:
Internet 204.189.124.205 0 001a.a01f.4e5a ...
|
by: bips2005 |
last post by:
i have got two tables,one customer with fields cust_id,email and another with field cust_id,domname,expirydate. i have this query to combine these two tables to give me email and the expirydate as
...
|
by: Jonathan Austin |
last post by:
My question is basically how would I be able to assign certain data automatically in a pattern (i.e. If employee1 is Alpha, employee2 is Bravo, employee3 is Charlie so on and so forth). How would I...
|
by: trixxnixon |
last post by:
say i want to query a few fields from a table for the purposes of a report. how might i have the query only return records that have data in at least one of the fields to prevent the repot from...
|
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,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
|
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: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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,...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |