티스토리 뷰

MySQL

190830 기본 명령문 예제

猫猫 2019. 8. 30. 17:28
반응형
use employees;
select * from employees;
SELECT * FROM employees.score2;
select name,total,vag from employees.score2 where vag>=70;
select * from employees.employees;
select * from employees.employees where emp_no=110303;
select * from employees.employees;
select * from employees.employees where gender='m' and hire_date <='1990-01-01';
select * from employees.employees where hire_date <='1992-01-01' and month(birth_date) = 9;
select * from employees.employees where (hire_date <'1995-01-01' and gender='F') or (emp_no between 10003 and 10009);
create table empresult (select emp_no,hire_date from employees.employees where first_name like 'm%' or first_name like 'k%');
select * from empresult;

select * from employees.employees where (first_name like 'm%' or first_name like 'k%') and gender='m';

select * from employees.employees where last_name='s%' = 
	any(select last_name from employees.employees where (first_name like 'm%' or first_name like 'k%' )and gender='M');

create table first_nametest select gender from employees.employees where (first_name like 'm%' or first_name like 'k%');
select * from employees.employees where gender = 'm';
select * from employees.employees where (gender='m') = any(select gender from employees.employees where emp_no <= 10100);
use employees;
SELECT * from employees.employees where (first_name like 'm%' or first_name like 'k%') and gender='M' and last_name =
	any(select last_name from employees.employees WHERE last_name like 's%');]
    
    
select * from employees where (first_name like 'M%' or first_name like 'K%')
	and gender='m' and last_name in(select last_name from employees 
		where gender='f' and last_name like 's%');
        
select * from employees where (first_name like 'M%' or first_name like 'K%')
	and gender='m' and last_name = any(select last_name from employees 
		where gender='f' and last_name like 's%');

select gender, count(*) from employees.employees group by gender;
select birth_date,count(*) from employees.employees GROUP BY birth_date;







반응형

'MySQL' 카테고리의 다른 글

190830 mysql in, out 프로시저  (0) 2019.09.09
mysql max_allowed_packet 에러  (0) 2019.09.03
190829 기본 명령문 예제  (0) 2019.08.30
190829 DB insert into 기본  (0) 2019.08.30
190829_01 기본문  (0) 2019.08.30