참고
MySQL Documentation 13.1.17 CREATE PROCEDURE and CREATE FUNCTION Statements
prerequisite
- CREATE ROUTINE 권한을 가지고 있어야 한다.
추가 설명
- 기본적으로 MySQL은 routine을 만든 생성자에게 ALTER ROUTINE과 EXECUTE 권 …
MySQL Documentation 13.1.17 CREATE PROCEDURE and CREATE FUNCTION Statements
Input:
Signups table:
+---------+---------------------+
| user_id | time_stamp |
+---------+---------------------+
| 3 | 2020-03-21 10:16:13 |
| 7 | 2020-01-04 13:57:59 |
| 2 | 2020-07-29 23:09:44 |
| 6 | 2020-12-09 10:39:37 |
+---------+---------------------+
Confirmations table:
+---------+---------------------+-----------+
| user_id | time_stamp | action |
+---------+---------------------+-----------+
| 3 | 2021-01-06 03:30 …
Input:
Patients table:
+------------+--------------+--------------+
| patient_id | patient_name | conditions |
+------------+--------------+--------------+
| 1 | Daniel | YFEV COUGH |
| 2 | Alice | |
| 3 | Bob | DIAB100 MYOP |
| 4 | George | ACNE DIAB100 |
| 5 | Alain | DIAB201 |
+------------+--------------+--------------+
Output:
+------------+--------------+--------------+
| patient_id | patient_name | conditions |
+------------+--------------+--------------+
| 3 | Bob | DIAB100 MYOP |
| 4 | George | ACNE DIAB100 |
+------------+--------------+--------------+
Explanation: Bob and George both have a condition that …
MySQL Documentation 13.6.5.6 REPEAT Statement
SELECT EXISTS
(
SELECT 1
FROM CVVE_POINT.CPO_POINT_EARN cpe, CVVE_CUSTOMER.CR_CUSTOMER cc
WHERE cpe.CR_ID = cc.CR_ID
AND cpe.CUH_ID = cc.CUH_ID
AND cpe.CPE_ISSUE_DT BETWEEN DATE_ADD …
id | name | salary | managerId |
---|---|---|---|
1 | Joe | 70000 | 3 |
2 | Henry | 80000 | 4 |
3 | Sam | 60000 | |
4 | Max | 90000 |
SELECT e1 …
직원들 중 1990년도에 Customer Service부서(dept_no='d009')에서 일 한 적이 있는 직원을 추출
SELECT
e.emp_no
,CONCAT(e.first_name, e.last_name) AS 'emp_name'
,d.dept_name
,de.from_date
,de.to_date …