제발 select 문 하나만 좀 만들어 주세요
테이블은 현재 두개가 있고 (member, command) 이 두 테이블을
이용해 뷰를
생성시켰습니다. (member_view)
member 테이블은 아래와 같이 생성 시켰고
create table member(
m_no char(8) not null,
m_name varchar(10) not null,
m_email varchar(20) no null,
m_password char(20) not null,
constraint pk_member_m_no primary key (m_no)
)
command 테이블은 아래와 같이 생성 시켰습니다.
create table command(
com_no char(10) not null,
com_date datetime not null,
com_note varchar(400),
com_m_no char(8) not null,
constraint fk_command_d_com_m_no foreign key (d_com_m_no)
references member (m_no),
constraint pk_command_d_com_no primary key (d_com_no)
)
그리고 이 두 테이블을 이용해 아래와 같이 뷰를 생성시
켰습니다.
create view member_view as
select
member.m_no as m_no,
member.m_name as m_name,
member.m_email as m_email,
command.com_note as m_note,
command.com_date as m_change_date,
from member,command
where member.m_no=command.com_m_no
여기서 뷰를 이용해서 오늘 날짜를 넘지 않는 m_change_date 중 가장
최근 것 하나만 (즉 m_no 가 중복되지 않게) 가지는 m_no와
m_change_date 그리고 m_note의 내용을 가지고 오는 select 문을 만들고
싶습니다.
(결과를 보면 마치 member_view에서 m_no가 주키 처럼 되고 각 m_no에
대한 최근 데이터 한개 씩만 나올 수 있도록 하는 쿼리문을
원합니다.)
답변해주시면 정말 감사하겠습니다.
|