Jump to content

Help! Need to update a table if a matching value is found in another table.


sptrsn

Recommended Posts

During a select statement, I was doing a lookup on the fly, checking to see if there was a matching value in a second table. The tables have become large enough that it's causing huge speed issues.

 

I don't need any data from the second table. I just need to know if a matching value exists.

 

So, I created a "tracking" field in table 1. My plan was to periodically do an update query and simply set a "1" or a "0" in the tracking field in the first table, IF there was a matching value in the second table. Then I could just add some conditional formatting or whatever, to have a visual clue that table 2 has data for me.

 

I can't figure out how to do it. I've been searching for examples for two hours and can't seem to figure it out.

 

Could one of you, who are obviously smarter than me, give me a clue how to go about this?

 

I've tried all kinds of retarded stuff.

It seems to me that it would be something like this... (but obviously these doesn't work)

UPDATE t1 SET `match` = '1' WHERE t1.apn = t2.apn 
or this
update t1 set match ='1' where select * from t1 as t1 join(select * from t2)t2 on t1.apn=t2.apn

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.