Searching equals records

  • Thread starter cmweb via AccessMonster.com
  • Start date
C

cmweb via AccessMonster.com

I have two tables named PERSONAL and CUSTOMER
PERSONAL table has fields : ID_PER, P_LASTNAME, (key = ID_PER)
CUSTOMER table has fields : ID_CUS, C_LASTNAME, (key = ID_CUS)

I need a process to review each LASTNAME in PERSONAL table and to search if
there is a equal LASTNAME in CUSTOMER.

How can I identify equals records and to save them in another table named
EQUALS ?

Thanks in advance
Carlos
 
K

Klatuu

You can easily do it with the query builder. Add both tables. Create a Join
on the fields you want to match, and select 1. The result of the query will
include rows only where the two fields are equal. It will produce SQL
something like this:

SELECT PERSONAL.P_LASTNAME, CUSTOMER.C_PASTNAME
FROM PERSONAL INNER JOIN CUSTOMER ON PERSONAL.P_LASTNAME =
CUSTOMER.C_PASTNAME;

You can add additional fields as you need, but that is the basics.
 
D

David Cox

If you have 30 Smiths in one table and 19 in the other, what do you want the
output to show?
 
C

cmweb via AccessMonster.com

Hi KLATUU
Thanks for you answer, but I need to review each record. Something like that:

do while not eof()
compare PERSONAL_lastname with CUSTOMER_lastname
if p_lastname = c_lastname then
save p_lastname in Table EQUALS
endif
skip
enddo
Is it possible ?
Thanks again
Carlos
 
C

cmweb via AccessMonster.com

Hi David
I explain you:
Persona table has unique names and if there is in customer table more than
one, I only save one.

I thought in a solution with DAO like that:

do while not eof()
compare PERSONAL_lastname with CUSTOMER_lastname
if p_lastname = c_lastname then
save p_lastname in Table EQUALS
endif
skip
enddo
Is it possible ?
Thanks again
Carlos


David said:
If you have 30 Smiths in one table and 19 in the other, what do you want the
output to show?
I have two tables named PERSONAL and CUSTOMER
PERSONAL table has fields : ID_PER, P_LASTNAME, (key = ID_PER)
[quoted text clipped - 9 lines]
Thanks in advance
Carlos
 
Top