MYSQL Workbench - ERROR CODE: 1046. NO DATABASE SELECTED
새 스키마 추가하는 방법
MySQL WorkBench로 샘플 데이터 다운로드 및 불러오기
UPDATE, DELETE를 하기 위해서는 MySQLWorkbench - settingㄴ(preferences) - SQL Editor - Safe Updates - 체크 해제 - MySQLWorkbench 재실행
-> 체크 표시가 되어있으면 UPDATE, DELETE가 불가
CREATE
update my_city set city_name = '서울' where city_name = 'seoul';
insert into my_city select Null, name, population from world.city;
insert into my_city (city_name, population) select name, population from world.city;
update my_city set city_name = '서울' where city_name = 'seoul';
delete from my_city where city_name like 'new%';
truncate table my_city;
truncate table my_city;
with table1 as (
select course_id, count(distinct(user_id)) as cnt_checkins from checkins
group by course_id
), table2 as (
select course_id, count(*) as cnt_total from orders
group by course_id
)
select c.title,
a.cnt_checkins,
b.cnt_total,
(a.cnt_checkins/b.cnt_total) as ratio
from table1 a
inner join table2 b on a.course_id = b.course_id
inner join courses c on a.course_id = c.course_id