create table TB_BATCH(
ID int(11) not null auto_increment,
BATCH_NO VARCHAR(32) comment '批次号',
CONTRACT_ID int(11) comment '合同ID',
CONTRACT_NO VARCHAR(64) comment '合同编号',
RULE_ID int(11) comment '规则ID',
CITY VARCHAR(64) comment '城市',
COMPANY_NAME VARCHAR(128) comment '企业名称',
SERVICE_ADDRESS VARCHAR(128) comment '上门地址',
EXP_DATE date comment '日期',
EXP_BEGIN_TIME time comment '开始时间',
EXP_END_TIME time comment '结束时间',
MASSAGIST_COUNT int(4) comment '技师数量',
STATUS VARCHAR(16) not null comment '状态:待分配、已分配、已确认、服务中、已完成、已取消',
OPERATOR varchar(30),
CREATE_TIME datetime,
MODIFY_TIME datetime,
primary key (ID)
);
create table TB_BATCH_MASSAGIST(
ID int(11) not null auto_increment,
MASSAGIST_ID int(11) not null,
MASSAGIST_NAME VARCHAR(32) not null,
BATCH_ID int(11) not null,
STATUS VARCHAR(16) not null comment '状态:NORMAL("待确认"), ASSIGNED("已确认"), IN_SERVICE("服务中"), COMPLETED("已完成")',
OPERATOR varchar(30),
CREATE_TIME datetime,
MODIFY_TIME datetime,
primary key (ID)
);
select A.* from TB_BATCH A left join TB_BATCH_MASSAGIST B on A.ID = B.BATCH_ID 查询出来的记录显示
发现记录重复
select A.* from TB_BATCH A left join TB_BATCH_MASSAGIST B on A.ID = B.BATCH_ID group by A.ID ,查询结果如下