Link to home
Create AccountLog in
Avatar of thenone
thenone

asked on

Best Possible solution

What I am trying to do is compare table columns.I have a record from table column1 A and what I want to do is try to find it in table B column1.If its found then Table Column2 which is an integer value will be plus 1.
Avatar of aikimark
aikimark
Flag of United States of America image

Update TableA Inner Join TableB on TableA.Column1 = TableB.Column1
Set Column2 = Column2 + 1
Avatar of thenone
thenone

ASKER

The thing is I have a bunch of records that need to be compared with.
<<The thing is I have a bunch of records that need to be compared with.>>
So if it exists anywhere in column1 of tableB, you want to increment it?

Update TableA
Set Column2 = Column2 + 1
Where Exists (Select * From TableB Where TableA.Column1 In TableB.Column1)
ASKER CERTIFIED SOLUTION
Avatar of Alexandre Simões
Alexandre Simões
Flag of Switzerland image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of thenone

ASKER

aikmark yes.I think using a combination of a query and stepping through each record and query against b would work.
Avatar of thenone

ASKER

So basically I could have a for loop or soemthing and then execute the query correct?

Update TableA
Set Column2 = Column2 + 1
Where Exists (Select * From TableB Where TableA.Column1 In TableB.Column1)
Avatar of thenone

ASKER

Alexcode i am using vb6 and your right using that function would slow everyhting down.How can I do it by using a query against one record at a time?
No looping required.  Let the database engine do all the work for you.  You will have adequate performance if there are indexes on the two columns.
Avatar of thenone

ASKER

aikmark how would I impliment that into a command.execute

my database is mysql 5.0

Also I see what your saying it will compare one table column with the other table column with one query much faster.
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.