我有两个表名为:
specific_product_id astatus ...
(primary_key,autoinc)
--------------------------------------
1 APAST ...
2 ALIVE ...
3 ALIVE ...
4 APAST ...
5 APAST ...
Run Code Online (Sandbox Code Playgroud)
own_id specific_product_id details
----------------------------------------
1 1 XXXX
2 5 XXXX
Run Code Online (Sandbox Code Playgroud)
我需要选择atatus = APAST,而不是在表2中.
这意味着,在上面的结构中,table1有3个APAST状态(1,4,5).但是在表2中,specific_product_id(1,5)只存储了所以我需要选择specific_product_id = 4
我用过这个查询
SELECT *
FROM table_product
WHERE astatus = 'APAST'
AND specific_product_id NOT IN (SELECT specific_product_id
FROM table_user_ownned_auction )
Run Code Online (Sandbox Code Playgroud)
......这需要很长时间:
查询花了115.1039秒
...执行.

我如何优化它或任何其他方式来选择我想要的?