오늘은 관계형 데이터베이스 실습 마지막날이다. 어제 DB Connection 이슈 처리하고 크게 어려운 내용은 없었다. 주어진 내용대로 쿼리를 날리면 끝난다. 하지만 그 쿼리가 조금 복잡했다. 특히 몇몇 문제는 SQL문이 계속 길어지게 되더라.
오늘 블로깅 할 내용은 실습한 쿼리중에 기억할만한 내용을 쓰고싶다. 
가장 처음 콘솔을 열고 치는 명령어. use로 database 들어가서 show tables;로 테이블을 확인할 수 있다. 그 이후 DESC users 명령어로 컬럼 정보를 확인할 수 있다.
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| learnmysql         |
| mysql              |
| performance_schema |
| sakila             |
| sys                |
+--------------------+
JOIN 테이블을 거쳐서 목표 테이블에 접근해야된다.
SELECT category.name FROM user 
      JOIN content ON user.id = content.userId 
      JOIN content_category ON content.id = content_category.contentId 
      JOIN category ON content_category.categoryId = category.id
                    WHERE user.name="jiSungPark"
SELECT 문법에서 COUNT외에 다른 항목을 불러올 경우 GROUP BY로 관련있는 항목을 묶어줘야된다.
그러지 않을 경우 아래 에러가 발생한다.
ERROR 1140 (42000): In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'learnmysql.user.name'; this is incompatible with sql_mode=only_full_group_by
SELECT user.name AS name, COUNT(content.userId) AS ContentCount FROM user
      LEFT JOIN content ON content.userId = user.id
      GROUP BY user.name