-1
我有兩個表獲取與PHP(語法)的外鍵
Create TABLE Comment(
CommentText TEXT,
CommentDate DATE NOT NULL,
Time time,
PostedBy VARCHAR(30),
FOREIGN KEY (PostedBy) REFERENCES Employee(Name)
);
Create TABLE Employee(
Name VARCHAR(30),
Title VARCHAR(30),
Onshift BOOLEAN,
PRIMARY KEY(Name)
);
現在我該怎麼辦下面
$Comments = mysql_query("SELECT * FROM Comment");
$all_comments = array();
while($row = mysql_fetch_array($Comments)) {
$all_comments[] = $row;
}
foreach($all_comments as $commentrow){
if($commentrow['PostedBy']){ //Check if The Employee is Onshift
Echo("The employee was on shift");
}
else{
Echo("The employee was on shift");
}
}
IE給出的外鍵(postedby)查找在另一個值foregin密鑰表(在這種情況下,如果布爾值,如果員工正在轉移?)
感謝您的回答,希望我能同時接受你的答案:/ – anders 2013-05-10 15:15:05