목록데이터베이스 (36)
개발은 처음이라 개발새발
2024.02.20 - [mysql] - [MySQL] MySQL Installer를 활용해 버전 관리하기 [MySQL] MySQL Installer를 활용해 버전 관리하기 https://dev.mysql.com/downloads/installer/ MySQL :: Download MySQL Installer Note: MySQL 8.0 is the final series with MySQL Installer. As of MySQL 8.1, use a MySQL product's MSI or Zip archive for installation. MySQL Server 8.1 and higher also bundle MySQL data-so-hard.tistory.com 지난 번에 MySQL Install..
https://dev.mysql.com/downloads/installer/ MySQL :: Download MySQL Installer Note: MySQL 8.0 is the final series with MySQL Installer. As of MySQL 8.1, use a MySQL product's MSI or Zip archive for installation. MySQL Server 8.1 and higher also bundle MySQL Configurator, a tool that helps configure MySQL Server. dev.mysql.com MySQL 버전 관리를 할때 MySQL Installer를 사용하면 편하게 버전 관리를 할 수 있습니다. 위에 링크를 통해 My..
SELECT * REPLACE('대체할 값'AS'컬럼명') SQL에서도 불러올 값을 간단하게 혹은 금액 같은 경우 원화에 맞게 환산해 대체할 수 있는 함수가 있습니다. REPLACE()함수를 활용하면 됩니다. 예제는 아래와 같습니다. -- REPLACE()함수 예제 SELECT * REPLACE(price * 10000 AS price) FROM `olist.olist_order_items`
SELECT * EXCEPT('제외할 컬럼') SQL에서 필요 없는 컬럼을 빼고 불러오고 싶은 경우, 간단한 방법은 필요한 컬럼을 모두 적는 것이지만 필요한 컬럼이 굉장히 많고 필요 없는 컬럼이 적을 경우 EXCEPT 함수를 사용하는 게 현명하다. --EXCEPT() 함수 예제 SELECT * EXCEPT(shipping_limit_date, freight_value) FROM `olist.olist_order_items`
https://leetcode.com/problems/consecutive-numbers/ Consecutive Numbers - LeetCode Can you solve this real interview question? Consecutive Numbers - Table: Logs +-------------+---------+ | Column Name | Type | +-------------+---------+ | id | int | | num | varchar | +-------------+---------+ id is the primary key for this table. id is an leetcode.com Input: Logs table: +----+-----+ | id | num | +..
https://www.hackerrank.com/challenges/the-report/problem?h_r=internal-search The Report | HackerRank Write a query to generate a report containing three columns: Name, Grade and Mark. www.hackerrank.com 이번에는 join 구문에서 between절을 활용하는 퀴즈를 풀어보려고 합니다. 흔히 join 구문에서 두 테이블을 매칭 시킬 때 on을 적고 그안에 각각의 테이블에서 매칭 시킬 수 있는 컬럼을 "A.컬럼 = B.컬럼 " 이런식으로 적는게 기본인데요. 하지만 모든 상황과 테이블들이 이 같은 구문으로 해결될순 없겠죠. 그렇기에 하나의 구문에서 어떻게..
https://www.hackerrank.com/challenges/challenges/problem?h_r=internal-search Challenges | HackerRank Print the total number of challenges created by hackers. www.hackerrank.com 이번 문제는 손이 많이 가는 서브쿼리 퀴즈인데요. 우선 예제를 살펴보겠습니다. 네 문제는 Hackers와 Challenges라는 두 테이블을 가지고 문제를 푸는 것입니다. 이 문제가 어려운 이유는 조건인데요. 조건을 간단하게 요약하면 다음과 같습니다. ###조건 조건1. hacker_id 별 name과 challenges의 개수를 구해라 조건2. hacker_id 별 최대 challenges를..
https://leetcode.com/problems/department-highest-salary/ Department Highest Salary - LeetCode Can you solve this real interview question? Department Highest Salary - Table: Employee +--------------+---------+ | Column Name | Type | +--------------+---------+ | id | int | | name | varchar | | salary | int | | departmentId | int | +--------------+--- leetcode.com Input: Employee table: +----+-----..
https://www.hackerrank.com/challenges/earnings-of-employees/problem?h_r=internal-search Top Earners | HackerRank Find the maximum amount of money earned by any employee, as well as the number of top earners (people who have earned this amount). www.hackerrank.com 이번에는 해커랭크의 서브쿼리 퀴즈를 풀어보겠습니다. 문제는 employee라는 테이블이 있고 그안에 아이디와, 이름, 개월수, salary의 컬럼으로 형성돼 있는데요. 문제는 개월수(months)와 salary를 곱한 값이 최대 몇이고 이 ..
서브쿼리는 SELECT , FROM ,WHERE 절까지 곳곳에서 많이 사용합니다. 저는 개인적으로 실무를 하면서 서브쿼리를 자주 사용하는데요. 이유는 여러가지가 있겠지만 대표적인 이유로는 특정 테이블의 하나의 조건 혹은 하나의 컬럼만 필요한데 굳이 JOIN을 하게 되면 여러모로 불편한 점이 생기기 때문입니다. 1. SELECT절에 사용하는 서브쿼리 - SELECT절에서 사용하는 서브쿼리를 스칼라 쿼리라고 하는데요. SELECT 절에서 사용하는 서브쿼리의 특징으로는 불러오는 값을 하나만 지정해야 한다는 점입니다. SELECT절 서브쿼리는 나중에 따로 더 다뤄보도록하겠습니다. 2. FROM절에 사용하는 서브쿼리 https://data-so-hard.tistory.com/78 서브쿼리를 활용한 DELETE [..