일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- 자바 #인터페이스 #추상클래스 #abstract #
- GoF #빌더패턴 #Builder Pattern
- PostgreSQL
- 프록시패턴 #Gof #ProxyPattern #Proxy
- Bridge Pattern #구조패턴 #Structure Pattern
- CentOS
- MariaDB #DB #기본쿼리 #select
- GOF #
- 데이터베이스
- Today
- Total
개발자 기초부터 시작하기
MariaDB - Select 기본 활용법 본문
데이터베이스 및 테이블은 MariaDB 깔면 기본적으로 제공되던 데이터셋을 활용했습니다.
-- select 기본
select * from departments;
select first_name, gender, hire_date from employees;
-- alias (별명) 미활용.
select concat(first_name, ' ', last_name), gender,hire_date from employees;
-- alias (별명) 활용
select concat(first_name, ' ', last_name) as '이름', gender as '성별', hire_date as '입사일' from employees;
-- titles 테이블안의 title 컬럼의 중복값을 제거하고 보여줌.
select distinct(title) from titles;
-- order by asc 와 desc
select concat(first_name, ' ', last_name) as '이름',
gender as '성별',
hire_date as '입사일'
from employees order by hire_date desc;
-- 2001년도에 받았던 급여들에 대한 내용
select emp_no, salary,from_date from salaries where from_date like '2001%';
-- 2001년도에 받았던 급여들에 대한 내용 중 급여의 내림차순.
select emp_no, salary,from_date from salaries where from_date like '2001%' order by salary desc;
-- 1991-12-31 이전 입사자들을 출력.
select concat(first_name, ' ', last_name) as '이름',
gender as '성별',
hire_date as '입사일'
from employees
where hire_date <= '1991-12-31';
-- 1988-12-31 이전 입사자 중 여자
select concat(first_name, ' ', last_name) as '이름',
gender as '성별',
hire_date as '입사일'
from employees
where hire_date <= '1988-12-31' and gender = 'f';
select emp_no, dept_no from dept_emp
where dept_no in ('d005','d009');
'데이터베이스 > MySQL 와 Maria DB' 카테고리의 다른 글
Maria DB - 여러 테이블간의 join 연습해보기 (0) | 2019.05.08 |
---|---|
Maria DB - 날짜형 함수들에 대한 정리 (0) | 2019.05.08 |