I'm trying to run two MySQL queries on tables with no matching columns. The results of these two queries need to be matched up and present information only if a portion of one column matches a column from the other database. Here is what I have so far:
select data2, time_id from db.table1
where data2 in
(select right(dst,10) from db2.table2
where calldate like '2012-09-01%' and lastdata like <blocked for privacy>)
having (time_id between '1346475600' and '1346562000');
In my understanding, the subquery on lines 3-4 should be called first, correct? My issue with this statement is that it always times out. It just takes too long. Am I formatting this incorrectly? I'm sure an alternative would be to use a join
statement, and any help in that direction would be great.