- 论坛徽章:
- 0
|
目的是删除ab_url表中mainhash字段不在ab_data表中mainhash字段的数据记录,查询的结果如下:- select ab_url.mainhash from ab_url left join ab_data on ab_url.mainhash = ab_data.mainhash where ab_data.mainhash is null;
复制代码- +----------------------------------+
- | mainhash |
- +----------------------------------+
- | NULL |
- | 0000070c44b6c2c792efeb5ce2ed8109 |
- | 00022babbf720ed0e5c0df566a1baac0 |
- | 00060e9e44c7446fae4ab84e068a1298 |
- | 0006707b2c42f5e99977cfb8458ec668 |
- | 000a7b914dffa38b95eba2d5bc06e403 |
- | 000fe9861acfaf8748ff043a15930bcd |
- | 00113de7d39f0f26d77a367eff04b9d0 |
- | 001282891104656804f2612c0e8db968 |
- | 00160a4854c8c871ffef57ca18fac34e |
- +----------------------------------+
复制代码 这些数据我现在无法使用- delete from ab_url left join ab_data on ab_url.mainhash = ab_data.mainhash where ab_data.mainhash is null
复制代码 ;语句删除,
当尝试用- delete ab_url,ab_data from ab_url left join ab_data on ab_url.mainhash = ab_data.mainhash where ab_data.mainhash is null
复制代码 ;语句时,发现执行时间特别长,不知该语句是否真有效,望各位兄弟指点迷津!谢谢
另外,表结构- mysql> desc ab_url;
- +-----------+---------------+------+-----+---------+-------+
- | Field | Type | Null | Key | Default | Extra |
- +-----------+---------------+------+-----+---------+-------+
- | url | varchar(1024) | YES | | NULL | |
- | urlhash | varchar(40) | NO | PRI | | |
- | mainhash | varchar(40) | YES | MUL | NULL | |
- | dir | varchar(32) | YES | | NULL | |
- | filename | varchar(512) | YES | | NULL | |
- | flag | int(4) | YES | | 0 | |
- | uptime | datetime | YES | | NULL | |
- | page_url | char(32) | YES | MUL | NULL | |
- | partorder | int(4) | YES | | 0 | |
- +-----------+---------------+------+-----+---------+-------+
- 9 rows in set (0.00 sec)
- mysql> desc ab_data;
- +-----------------+--------------+------+-----+---------+-------+
- | Field | Type | Null | Key | Default | Extra |
- +-----------------+--------------+------+-----+---------+-------+
- | uptime | datetime | YES | | NULL | |
- | filesize | double | YES | MUL | NULL | |
- | filename | varchar(512) | YES | | NULL | |
- | load_path | varchar(32) | YES | | NULL | |
- | server_ip | varchar(36) | YES | | NULL | |
- | adduction_num | int(4) | YES | | 0 | |
- | hits | int(4) | YES | | 0 | |
- | dir | varchar(32) | YES | | NULL | |
- | mainhash | varchar(40) | NO | PRI | | |
- | lastvisitedtime | datetime | YES | MUL | NULL | |
- | keyhash | varchar(40) | YES | | NULL | |
- | name | varchar(256) | YES | | NULL | |
- | page_name | varchar(512) | YES | | NULL | |
- | type | varchar(10) | YES | | NULL | |
- +-----------------+--------------+------+-----+---------+-------+
- 14 rows in set (0.00 sec)
复制代码 |
|