1
SELECT au.*
  FROM account au
  WHERE au.id IN (
    SELECT fa.from_user_id
      FROM approvals fa
      WHERE fa.to_user_id = 1
      GROUP BY fa.from_user_id
   )
 ORDER BY first_name ASC, last_name ASC
 LIMIT 0, 18446744073709551615;

我怎样才能将其更改为EXISTS而不是IN()

4

1 回答 1

0
SELECT au.* 
FROM account au 
WHERE EXISTS (
   SELECT 1 FROM approvals fa 
   WHERE fa.to_user_id=1 
     AND fa.from_user_id = au.id
) 
ORDER BY first_name ASC, last_name ASC LIMIT 0, 18446744073709551615;
于 2012-07-15T23:38:46.717 回答