0604 til

looggi·2023년 6월 4일
0

TILs

목록 보기
86/114
post-thumbnail

취소되지 않은 진료 예약 조회하기

SELECT a.apnt_no, p.pt_name, p.pt_no, a.mcdp_cd, d.dr_name, a.apnt_ymd
from appointment a
join doctor d
on a.mddr_id=d.dr_id
join patient p
on p.pt_no=a.pt_no
where a.mcdp_cd='cs' 
  and date_format(APNT_YMD,'%Y-%m-%d')='2022-04-13' 
  and a.apnt_cncl_yn='n'
order by a.apnt_ymd

다른사람꺼 🥷

SELECT
A.APNT_NO, P.PT_NAME, P.PT_NO, D.MCDP_CD, D.DR_NAME, A.APNT_YMD
FROM APPOINTMENT A, DOCTOR D, PATIENT P
WHERE A.MDDR_ID = D.DR_ID AND A.PT_NO = P.PT_NO
AND A.APNT_CNCL_YN = 'N'
AND TO_CHAR(A.APNT_YMD,'YYYYMMDD') = '20220413'
AND D.MCDP_CD = 'CS'
ORDER BY A.APNT_YMD

join을 굳이 할 필요가 없을 때는 from 에 테이블 다 써주고 where에 join조건 써줘도 되나보다
그리고 tochar() 여기서 날짜 형식을 바꿔서 비교했는데 이게 더 쓰기가 편할 것 같다 잇츠굿~~~

profile
looooggi

0개의 댓글