Check out example codes for "insert to first table if field A equals field B from a second table using sql". It will help you in understanding the concepts better.
Code Example 1
UPDATE Table_1 SET Field_X = (SELECT Field_Y FROM Table_2 WHERE Table_1.Field_A=Table_2.Field_B LIMIT 1)
Learn ReactJs, React Native from akashmittal.com