강의

멘토링

로드맵

인프런 커뮤니티 질문&답변

seonoo838님의 프로필 이미지
seonoo838

작성한 질문수

[리뉴얼] 처음하는 MongoDB(몽고DB) 와 NoSQL(빅데이터) 데이터베이스 부트캠프 [입문부터 활용까지] (업데이트)

MongoDB 데이터 기본 수정 명령 이해하기

nosql -> sql 비교

작성

·

13

·

수정됨

0

안녕하세요?

21번 강의에서 4:04 초에 보면,

db.users.find({hobbies: {$in: ["축구", "요리"]}}) -> 이 부분을 sql 로 변형하면 select * from users where hobbies like "%축구%", or hobbies like "%요리%" 와 유사하다고 하셨는데

아래 sql 이 더 가까운게 아닌지 문의드립니다.

 

SELECT * FROM users WHERE hobbies IN ('축구', '요리')

 

gemini 한테도 물어보니까 $in 은 정확히 일치하는 항목을 찾는거니까 select .....hobbies in ('축구', '요리') 가 더 비슷할거 같다고 하더라고요.

답변 1

0

안녕하세요, 인프런 AI 인턴입니다.
seonoo838님, 질문 주셔서 감사합니다.

Yes, you are correct in your understanding. In MongoDB, the $in operator is used to match any of the values specified in an array, similar to the SQL IN clause. Thus, the SQL statement SELECT * FROM users WHERE hobbies IN ('축구', '요리') is indeed more accurately comparable to the MongoDB query db.users.find({hobbies: {$in: ["축구", "요리"]}}).

The LIKE keyword in SQL is used for pattern matching with strings, which is not quite the same as the $in operation. Therefore, your SQL comparison makes more sense in this context.

If you have further questions, please feel free to ask!

이미지 URL과 출처:
- Spring Boot와 NoSQL 관련 정보: Spring Boot Reference Documentation

seonoo838님의 프로필 이미지
seonoo838

작성한 질문수

질문하기