表结构:3个字段
task_id guid task_status
其中task_id为key
查询语句:
select task_id from tab_task where guid not in (select guid from tab_task where task_status in(1,2));
子查询再加上not in, 速度实在是太慢了,请教该如何优化?
task_id guid task_status
其中task_id为key
查询语句:
select task_id from tab_task where guid not in (select guid from tab_task where task_status in(1,2));
子查询再加上not in, 速度实在是太慢了,请教该如何优化?
select task_id from tab_task where task_status<>1 and task_status<>2;
select a.task_id from tab_task a from tab_task b
on a.guid=b.guid where b.guid is null and b.task_status in(1,2)
2.与选择出的task具有相同的guid的task没有task_status为1或者2的可能字段名字用guid会让大家误解,不过多个task是可以有相同的guid的
select a.task_id from tab_task a INNER JOIN tab_task b
on a.guid=b.guid where b.guid is null and b.task_status in(1,2)
ON a.guid=b.guid AND b.task_status IN(1,2) WHERE b.guid IS null将INNER JOIN->LEFT JOIN
笔误