UMfan Posted January 17, 2007 Share Posted January 17, 2007 I'm a newbie, and having help. Nobody has been able to help me with this in the mysql forum. :-\I have two tables: "fast" and "new data" Both have about 7 million rows. Both are InnoDB.I am running the query below in order to find the data that is in "new data" that is not in "Fast". I want to store these results in a third table called "Fall outs".My query (please note the subquery in the WHERE statement. This query works fine as a SELECT query, I only have problems when I add the "INSERT INTO" line):INSERT INTO `fall outs`SELECT (I have about 120 data fields I'm selecting here)FROM `new DATA` LEFT JOIN `fast` ON `new DATA`.`FB_ID` = `fast`.`FB_ID`WHERE`new DATA`.`BAT_CREAT_DTM` <= (SELECT MAX(`fast`.`BAT_CREAT_DTM`)FROM `fast`) AND `fast`.`fb_id` IS NULL;When I run this query I get an error that I've exceeded my number of locks. I did some research and found that I should modify my query so that it reads:SET @@AUTOCOMMIT=0;LOCK TABLES `fall outs` WRITE, `new data` READ;INSERT INTO `fall outs`SELECT (insert my select statement here)WHERE (insert my where statement here);UNLOCK TABLES; If I do this, I get an error that the table "fast" was not locked. So how do I modify the above so that I can lock "fall outs" as the WRITE table and lock both "fast" and "new data" as the READ tables?I'm also open to an easier way of doing this if anyone has suggestions.I'd really appreciate the help. I'm stuck on a project at work until I can overcome this. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.