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 に答える