I have two tables of integers in which I need to compare two columns as follow:
table_1
col1 | col2 | col3 |
table 2
col1 | col2 | col3 |
I need to copy the content of table_2.col3 INTO table_1.col3 If I have the following condition :
table_1.col1 >= table_2.col1
AND IF table_1.col2 <= table_2.col2
This is what I wrote on MySQL:
Code:
mysql> INSERT INTO table_1.col3
-> SELECT * FROM table_2.col3 WHERE
-> table_1.col1 >= table_2.col1
-> AND table_1.col2 <= table_2.col2;
The 1st issue I have is ... This doesn't work at all.. it returns that table_1.col3 doesn't exist (even thou it does exit..)
The 2nd issue is that MySQL would compare line 01 to line 01, then line 02 to line 02 for each table. Optimally I need it to compare line 01 of table_1 to each line in table_2 and then, go to line 02, compare it to each line in table_2 and so on..Is it possible?