I need some help to build a SQL query (in MySQL). I have two tables. Table 1 and Table 2 are sitting on different db host/schema.
Table1 has custid, tag, prod1id, prod2id, prod3id Table2 has custid, prodid
Now the query is to update the tag field of Table1. The field needs to be 1 if prod1id, prod2id, prod3id entries also exists in Table2 for a certain customer. Here is an example
Table1
custid, tag, prod1id, prod2id, prod3id
1 1 12 13 14
2 0 24 25 26
Table2
custid, prodid
1 12
1 13
1 14
2 24
2 26
The tag field for customer #2 is 0 because prod2id which is 25 does not exist in Table2. Could someone help me in forming the query?