• Home
  • About
    • Develop2r photo

      Develop2r

      안녕하세요 IT 개발자 임기남입니다. 한걸음 한걸음 나아가는 개발자를 꿈꾸고 있습니다.

    • Learn More
    • Twitter
    • Facebook
    • Instagram
    • Github
    • Steam
  • Posts
    • All Posts
    • All Tags
  • Projects
  • Algorithm

2020_상반기_넷마블_SQL

27 Jun 2020

Reading time ~1 minute

문제 풀이

  • 하나의 테이블에서 WHERE절 + 간단한 함수(not in)와 ORDER BY 이용

Code Snippets


select id from game_users
    where id not in (select id1 from friends)
    and id not in (select id2 from friends)
    order by id;


Improvements

select id from game_users
    where id not in (select distinct id1 from friends)
    and id not in (select distinct id2 from friends)
    order by id;

비교할 id1과 id2의 중복을 제거하여 비교할 대상을 줄여 성능향상가능하다고 생각한다.



SQLnetmable Share Tweet +1