473,398 Members | 2,525 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.

How to compare and identify data in array?

91
I have two columns which holds numerical values and both the columns are sorted.
I want to check if the data in the first column exists in the second column or not?

Eg.
Column A
1
2
3
4

Column B
1
2
4
5

I would like to check if the 1st cell value(=1) in Col A exists in Col B or not.

How can I compare and identify?

PS: I am trying to join two tables in access but it won't because the Parent - Child relationship has gone sour !

Please advise.

Thanks,
SG
Aug 8 '12 #1
4 2171
twinnyfo
3,653 Expert Mod 2GB
I would create two recordsets in VBA, cycle through the first recordset, and using the current value of the record, cycle through the second recordset. You may want to determine a way to save your results or print the records that are not found.

Then, determine what you want to do with your orphaned records...
Aug 8 '12 #2
sg2808
91
Thanks twinnyfo but I am absolutely zero with VBA. Any help would be greatly appreciated.
Aug 8 '12 #3
twinnyfo
3,653 Expert Mod 2GB
If you are slick enough with queries, you could create a LEFT JOIN query that will display all records from one table whether there is a corresponding record inthe other table. Then, set as the criteria for the record in table2 as Null.

Assuming you have Table1 and Table2 in the example you gave with said fields, this is what it should look like:

Expand|Select|Wrap|Line Numbers
  1. SELECT Table1.ColumnA
  2. FROM Table1 LEFT JOIN Table2 ON Table1.ColumnA = Table2.ColumnB
  3. WHERE Table2.ColumnB Is Null;
  4.  
In your example above, this would return the value of "3", since it is the only value in ColumnA not found in ColumnB.

Hope this helps.
Aug 8 '12 #4
zmbd
5,501 Expert Mod 4TB
sg2808,

Twinnyfo was really nice to help; however, normally you should really post what you've already tried to solve the problem.
http://bytes.com/topic/access/answer...-posting-forum

As you already have one answer... this uses a self join on the one table... same concept as Twinnyfo just no extra tables to create.

Table3 has Fields [f1] and [f2] as numeric using the data as given in OP. Checks [F1] against [F2].

I leave it to you tweek the table/SQL to add a record id.

Expand|Select|Wrap|Line Numbers
  1. SELECT Table3.f1
  2. FROM Table3 
  3.    LEFT JOIN Table3 AS Table3_Again 
  4.       ON Table3.f1 = Table3_Again.f2
  5. WHERE (((Table3_Again.f2) Is Null));
  6.  
-z
Aug 8 '12 #5

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

Similar topics

1
by: GitarJake | last post by:
Hello all, I am new to sql and have some Access experience. In sql, how do I: compare 2 identical tables, (except for data); then update table 1 with new data from table 2 TIA Jake
8
by: Jason Heyes | last post by:
If s is a std::string, does &s refer to the contiguous block of characters representing s?
12
by: geerrxin | last post by:
Hi, I have a need to manipulate a large matrix, say, A(N,N) (of real) 8GB which can't fit in physical memory (2 BG). But the nature of computation requires the operation on only a portion of...
1
by: rm | last post by:
I have seen several examples explaining the fact that a table containing a field for each day of the week is for the most part an array. An specific example is where data representing worked hours...
4
by: reva | last post by:
hi all!! can any one please help me in checking the two character arrays. in my code i need to compare a character array(seq) to that of hydrob and hydrop . if the seq has hydrob then it should be...
3
by: weetat | last post by:
Hi all, I need some advice regarding wrote a javascript function. The function purpose is to check the variable "selectedSeat", for e.g if the selectedSeat value is var selectedSeat =...
0
by: mwenz | last post by:
I am trying to update an Access table using OLEDB in VB.Net 2005. I can add rows but I cannot update them. Code to instantiate the Access database and table... Dim conn As New...
1
by: keith katthy | last post by:
Is it true I do like below, if I want to all data array? and the ouput is 2. How to know which array that computer take? #include <iostream> #include <conio.h> #include <cstdlib> #include...
3
by: wesley1970 | last post by:
<?php $a = array(1,2,3,4,5); $b = array(1,2,3,4,5,6,7,8); echo array_intersect($a, $b); ?> array_intersect should return the numbers of items intersect in 2 arrays. In this case, it...
12
by: Aditya sant | last post by:
Am spliting file string into array by using fgets(),and explode() On other hand am taking string from user,and again spliting it into array now I have 2 array when I compare 2 arrays by using...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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...
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.