Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/243.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php mysql连接添加新列_Php_Mysql - Fatal编程技术网

Php mysql连接添加新列

Php mysql连接添加新列,php,mysql,Php,Mysql,如何更改查询,使其同时添加“updatepersonal”表中的姓氏列?这听起来很简单,但似乎不起作用。我试着和patientId使用完全的外部连接 任何帮助都将不胜感激 $query = "select ts.theTime,d.doctorName, bMon.id as bMon, bTue.id as bTue, bWed.id as bWed, bThu.id as bThu, bFri.id as bFri from timeSlots ts cross join doctor

如何更改查询,使其同时添加“updatepersonal”表中的姓氏列?这听起来很简单,但似乎不起作用。我试着和patientId使用完全的外部连接

任何帮助都将不胜感激

$query = "select ts.theTime,d.doctorName, 
bMon.id as bMon, bTue.id as bTue, bWed.id as bWed, bThu.id as bThu, bFri.id as bFri 
from timeSlots ts 
cross join doctors d 
left join booking bMon 
on bMon.apptDate=@Monday and bMon.timeSlotId=ts.id and bMon.doctorId=d.doctorId 
left join booking bTue 
on bTue.apptDate=date_add(@Monday, INTERVAL 1 DAY) and bTue.timeSlotId=ts.id and bTue.doctorId=d.doctorId 
left join booking bWed 
on bWed.apptDate=date_add(@Monday, INTERVAL 2 DAY) and bWed.timeSlotId=ts.id and bWed.doctorId=d.doctorId 
left join booking bThu 
on bThu.apptDate=date_add(@Monday, INTERVAL 3 DAY) and bThu.timeSlotId=ts.id and bThu.doctorId=d.doctorId 
left join booking bFri 
on bFri.apptDate=date_add(@Monday, INTERVAL 4 DAY) and bFri.timeSlotId=ts.id and bFri.doctorId=d.doctorId 
cross join (select @Monday:='2015-11-30') params 
order by ts.theTime,d.doctorName;";
模式:

create table doctors 
(   doctorId int(4) primary key,
doctorName varchar(20) not null
);

create table timeSlots 
(
id int auto_increment primary key,
theTime time not null
);

insert into timeSlots (theTime) values ('09:00:00');    -- 1
insert into timeSlots (theTime) values ('10:00:00');    -- 2
insert into timeSlots (theTime) values ('11:00:00');    -- 3
insert into timeSlots (theTime) values ('12:00:00');
insert into timeSlots (theTime) values ('13:00:00');
insert into timeSlots (theTime) values ('14:00:00');
insert into timeSlots (theTime) values ('15:00:00');
insert into timeSlots (theTime) values ('16:00:00');
insert into timeSlots (theTime) values ('17:00:00');    -- 9

create table booking
(   surname varchar(20),
id int auto_increment primary key,
patientId int not null,
amORpm varchar(2),
doctorName varchar(20),
altamORpm varchar(1),
altdate varchar(1),
altdoctor varchar(1),
date date,
doctorId int not null,
apptTime time,
booked varchar(1)
apptDate date not null,
timeSlotId int not null,
doctorId int(4),
key(apptDate) -- index
);

create table updatepersonal (
surname varchar(20),
id int(4),
forename varchar(20),
DOB datetime,
doctorId  int not null,
contactno char(11),
email varchar(40),
address varchar(100),
PRIMARY KEY (id)
);

您必须使用哪个字段将updatepersonal表连接到任何其他表?patientId?我基本上需要它是另一个专栏后,星期五有所有患者的姓氏。你明白我想说的吗?我认为我的问题没有多大意义^^lol://@shadow我基本上需要它在我的结果表中的“Friday”之后添加另一列,以便从预约表中获得所有患者的姓氏。