Help!
Probably it is too easy, but I am not so experienced in MySQL up to now.
I have two tables table1&table2 with the following columns: col1 double,
col2 int(11), col3 date
I want to query:
INSERT INTO table2 SELECT col1,col2,col3 FROM table1
WHERE col2= ( SELECT MAX(col2)
FROM table1
WHERE table1.col1=tab le2.col1 AND
table1.col3=tab le2.col3
);
It is working fine, but not very fast. Do you know the best solution,
probably a multi-column index (INDEX indexname(col1, col3))? Or do I need
an index also for col2?
Thanks,
Matthias
Probably it is too easy, but I am not so experienced in MySQL up to now.
I have two tables table1&table2 with the following columns: col1 double,
col2 int(11), col3 date
I want to query:
INSERT INTO table2 SELECT col1,col2,col3 FROM table1
WHERE col2= ( SELECT MAX(col2)
FROM table1
WHERE table1.col1=tab le2.col1 AND
table1.col3=tab le2.col3
);
It is working fine, but not very fast. Do you know the best solution,
probably a multi-column index (INDEX indexname(col1, col3))? Or do I need
an index also for col2?
Thanks,
Matthias
Comment