todo 테이블 만들기
create table todo (id int(max) not null auto_increment, title varchar(100) not null, curdate text, write_id int(11) default null, primary key(id));
writer 테이블 만들기
create table writer(id int(11) not null auto_increment, name varchar(30) not null, profile varchar(30) default null,primary key(id));
샘플 데이터는 알아서 넣기
todo table에 write_id가 없어서 추가
ex)
update todo set write_id = 1 where id = 1;
writer table과 todo table left join (writer 테이블의 id가 todo 테이블의 write_id와 같을 경우) 다만 데이터가 예쁘게 나오지 않는다.
select * from todo left join writer on todo.write_id = writer.id;
writer table과 todo table left join (writer 테이블의 id가 todo 테이블의 write_id와 같을 경우)
select todo.id as todo_id, title, curdate, name, profile from todo left join writer on todo.write_id = writer.id;
nodejs mysql 연결
https://piaocanyi.tistory.com/321
Mysql node.js 연결 (mysql workbench 설치)
workbench 설치하기 (google에 workbench) 나는 d drive에 받겠다. my connection + todo가 생성됨 스키마에서 전체정보 확인가능 npm install -save node-mysql webserver.js 에서 Mysql 연 //MySql const mysql = require('mysql'); const c
piaocanyi.tistory.com