您可以使用以下查询:
SELECt table1.id FROM table1 LEFT JOIN table2 ON table1.id IN (table2.user_one, table2.user_two)WHERe table2.user_one IS NULL;
虽然,根据您的索引,
table2您可能会发现两个联接的性能更好:
SELECt table1.id FROM table1 LEFT JOIN table2 AS t1 ON table1.id = t1.user_one LEFT JOIN table2 AS t2 ON table1.id = t2.user_twoWHERe t1.user_one IS NULLAND t2.user_two IS NULL;



