我正在使用以下语句来填充Excel电子表格中的学生信息,其中包括“actualstudenthours”。SQL命令逻辑遇到问题 - 请帮助
问题是,我想向所有学生展示tblstudentstatus.id = 3,但我还需要显示这些学生的实际学生时间。不幸的是,并不是所有的学生都在“视觉学习时间”中有相应的条目。这种说法完全排除了那些没有相应的“观看时间”的学生。
我该如何让所有学生出现在tblstudentstatus.id = 3的位置?
如果在实际的时间里没有他们的入口,它不应该完全忽略学生......学生时间字段应该是空白的。你的帮助将不胜感激。
$result=mysqli_query($dbc,"SELECT tblstudent.first, tblstudent.last,
LEFT(viewactualstudenthours.ACTUAL_remain,5),
(SELECT first from tbladdress where tbladdress.id = tblstudent.contact2),
(SELECT last from tbladdress where tbladdress.id = tblstudent.contact2),
tbladdress.address1,tbladdress.city,tbladdress.state,tbladdress.zip1,
tbladdress.phone, tbladdress.cell, tbladdress.email
FROM tblstudent, tbladdress, tblstudentstatus, viewactualstudenthours
WHERE viewactualstudenthours.student_id = tblstudent.id
AND tblstudent.status = tblstudentstatus.id
AND tbladdress.id = tblstudent.contact1
AND tblstudentstatus.id = 3");
(注:在编辑器中进行SQL半清晰的 - 但可能打破在PHP代码书中的每个规则。)
通过缩进他们四个空格注意:您可以[格式线为代码(http://meta.stackexchange.com/questions/22186/how-do-i-format-my-code-blocks)。编辑器工具栏中的“{}”按钮可以为您做到这一点。编辑你的问题并尝试一下。单击编辑器工具栏中的橙色问号以获取更多信息和格式化提示。 – outis 2011-05-26 04:43:41
@junkyjunk:不,我不是。我的建议是“junkyjunk”,你今天注册的事实,您的用户名,可能会让人觉得你是曳。为了您参考:http://msmvps.com/blogs/jon_skeet/archive/2010/08/29/writing-the-perfect-question.aspx – 2011-05-26 04:50:10
我书签此网址 – Ibu 2011-05-26 04:57:47