join을 하면 강사님 화면에서처럼 author_id 번호를 기준으로 내림차순이 되는 게 아니라 topic의 id를 기준으로 되네요:(
강제로
SELECT * FROM topic LEFT JOIN author ON topic.author_id=author.who ORDER BY author.who ASC;
로
order by를 넣어야 같게 표시가 되던데, 왜 join시에 자동으로 author_id와 id 기준이 아닌 topic table의 id를 기준으로 오름차순으로 정렬이 되는 걸까요..?
**참고로 위에 기입한 명령문에 id가 아니라 who인 것은 reserved words 때문에 변경했습니다.
SELECT *
FROM topic
LEFT JOIN author ON topic.author_id != author.id;
로 쿼리를 작성했을 때
topic.author_id = author.id 일 때 같은 값으로 매칭되어(1<->1, 2<->2, 3<->3) 결과 행이 5개였던 것과 달리
같은 것을 제외하고 모두 매칭되어(1<-> 2,3 / 2<->1,3/ 3<->1,2) 행이 10개가 됩니다!
SELECT * FROM topic LEFT JOIN author ON topic.author_id = author.id;
SELECT comment.id, description, name, profile FROM comment LEFT JOIN author ON comment.author_id = author.id;
테이블을 분리함으로써 데이터 하나를 바꾸면 관련있는 모든 테이블들의 정보를 바꿀 수 있다.