DROP TABLE IF EXISTS `t1`; DROP TABLE IF EXISTS `t2`; CREATE TABLE `t1` ( `a` varchar(255) default NULL,`b` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,KEY `bw_id` (`a`,`b`)) ENGINE=MyISAM DEFAULT CHARSET=latin1; CREATE TABLE `t2` ( `a` varchar(255) default NULL) ENGINE=MyISAM DEFAULT CHARSET=latin1; SET session sort_buffer_size=1024; INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-07 06:00:24'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-07 07:38:27'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-07 08:06:52'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-07 08:38:32'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-07 09:03:16'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-07 09:38:03'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-07 10:00:44'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-07 10:35:34'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-07 11:02:13'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-07 11:38:37'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-07 12:04:38'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-07 12:35:07'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-07 13:03:17'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-07 13:34:50'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-07 13:39:38'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-07 14:47:07'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-07 15:05:33'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-07 15:48:48'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-07 16:06:45'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-07 16:48:14'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-07 17:07:59'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-07 17:48:04'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-07 18:08:49'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-07 18:52:34'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-07 19:07:39'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-07 19:49:29'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-07 20:10:28'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-07 20:50:57'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-07 21:06:55'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-08 13:58:54'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-08 14:02:22'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-09 13:20:03'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-09 13:26:40'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-09 14:17:40'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-09 14:25:20'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-09 15:20:17'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-09 15:26:53'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-09 16:20:49'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-09 16:27:30'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-09 17:19:26'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-09 17:30:12'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-09 18:22:35'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-09 18:27:30'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-09 19:26:00'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-09 19:28:22'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-09 20:27:50'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-09 20:30:42'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-09 21:25:14'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-09 21:29:59'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-09 22:22:11'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-09 22:33:38'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-09 23:24:36'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-09 23:32:38'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-10 00:22:42'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-10 00:35:57'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-10 01:19:34'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-10 01:39:09'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-10 02:15:58'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-10 02:40:58'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-10 03:21:20'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-10 03:48:23'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-10 04:20:49'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-10 04:49:52'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-10 05:18:54'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-10 05:47:27'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-10 06:19:59'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-10 06:44:10'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-10 07:18:20'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-10 07:42:46'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-10 08:15:21'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-10 08:42:58'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-10 09:15:32'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-10 09:41:37'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-10 10:13:20'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-10 10:41:47'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-10 11:14:04'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-10 12:05:36'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-10 12:12:09'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-10 13:02:48'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-10 13:11:07'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-10 14:05:59'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-10 14:14:04'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-10 14:48:09'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-10 15:11:32'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-10 15:52:41'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-10 18:29:48'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-10 18:54:44'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-10 19:31:36'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-10 19:55:49'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-10 20:30:28'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-10 20:52:27'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-10 21:32:25'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-11 14:32:01'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-11 14:34:00'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-11 14:58:27'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-11 15:33:37'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-11 16:00:46'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-11 16:30:12'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-11 16:30:25'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-11 17:32:38'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-11 17:59:02'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-11 18:31:57'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-11 19:02:23'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-11 19:28:37'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-11 20:01:15'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-11 20:25:17'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-11 20:27:14'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-12 13:16:34'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-12 13:44:18'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-12 14:13:56'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-12 14:45:08'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-12 14:48:34'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-12 19:53:48'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-12 19:56:20'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-13 01:51:48'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-13 02:51:51'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-13 02:58:36'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-13 03:53:17'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-13 03:56:24'); INSERT INTO `t1` VALUES ('abcdefghijk','2007-05-13 21:01:36'); INSERT INTO `t1` VALUES ('asdf','2007-02-08 01:11:26'); INSERT INTO `t2` VALUES ('abcdefghijk'); INSERT INTO `t2` VALUES ('asdf'); select 1 from (select (select 1 from t1 where t1.a=t2.a order by t1.b limit 1) as d1 from t2) as d2;