본문 바로가기

국비과정/팀프로젝트

[Thread] 토이프로젝트 관련 정리

[ ThreadBoard ] 

bno , m_no ,  bcontent , blike , bdate , b_del

 

 

[ ThreadMember ]

m_no , m_id , m_pw , m_name , m_gender , m_addr , m_em , m_ph ,

m_birth , m_grade , m_intro , m_profileImage

 

[ ThreadComments ] 

cno , m_no , bno , c_comment , c_date , c_like , c_del , c_likeon

 

[ Follow  ]

fno , fromUser, toUser, fdate, m_id, m_id2

             m_id2     m_id


 

[ ThreadBoardview  코드 ] _ThreadBoard & ThreadMember 조인

 

select `t`.`bno` AS `bno`,

`t`.`bcontent` AS `bcontent`,

`m`.`m_id` AS `m_id`,

if(date_format(current_timestamp(),'%Y-%m-%d') = 

date_format(`t`.`bdate`,'%Y-%m-%d'),date_format(`t`.`bdate`,'%H:%i:%s'),

date_format(`t`.`bdate`,'%Y-%m-%d')) AS `bdate`,

`t`.`blike` AS `blike`,

(select count(0) from `ThreadComments` 

where `ThreadComments`.`bno` = `t`.`bno` and `ThreadComments`.`c_del` = '1') AS `commentcount

from (`ThreadBoard` `t` join `ThreadMember` `m` on(`t`.`m_no` = `m`.`m_no`)) 

where `t`.`b_del` = 1 

order by `t`.`bno` desc

 

( bno 의 역순으로 )

1. ThreadBoard 의 bno , m_no ,  bcontent , blike , bdate  

2. ThreadBoard bno ThreadComments bno 가 일치하는 값들 중에서

c_del = 1인 것들의 갯수인 commentcount 

3. b_del 값이 1인 것들만 불러오는 조건도 걸어줬는데 b_del 을 사용하진 않았다.

 


[ ThreadCommentsview  코드 ] _ThreadMember & ThreadComments 조인

 

select `c`.`cno` AS `cno`,

`c`.`m_no` AS `m_no`,

`c`.`bno` AS `bno`,

`m`.`m_id` AS `m_id`,

`m`.`m_name` AS `m_name`,

`c`.`c_comment` AS `c_comment`,

`c`.`c_date` AS `c_date`,

`c`.`c_like` AS `c_like

from (`ThreadMember` `m` join `ThreadComments` `c` on(`c`.`m_no` = `m`.`m_no`)) 

where `c`.`c_del` = 1

 

 

 ( c_del = 1 인 값들중에서 )

1. ThreadCommentscno , m_no , bno , m_comment , c_date , c_like 

2. ThreadMemberm_id , m_name 


[깃헙]

https://github.com/haehyunpyo/jul14.git