第一个查询有效并显示正确的结果。当我添加额外的 AND 条件时,我收到“试图获取非对象的属性”错误。我可以在一个 OR 和另一个条件下成功执行。这是回显的查询:SELECT * FROM scores WHERE (sortDate <= 20190629 AND sport = football) AND (homeID = 4 OR awayID = 4) ORDER BY gameDate DESC我确定变量正在通过。这个工作正常:$sql = "SELECT * FROM scores WHERE sortDate <= $todayAND (homeID = $teamID OR awayID = $teamID)ORDER BY gameDate DESC";这个给出了一个错误(添加了 AND):$sql = "SELECT * FROM scores WHERE (sortDate <= $today AND sport = $sportID)AND (homeID = $teamID OR awayID = $teamID)ORDER BY gameDate DESC";
1 回答
狐的传说
TA贡献1804条经验 获得超3个赞
尝试这个
$sql = "SELECT * FROM scores
WHERE (sortDate <= $today AND sport = '$sportID')
AND (homeID = $teamID OR awayID = $teamID)
ORDER BY gameDate DESC";
或者
$sql = "SELECT * FROM scores
WHERE (sortDate <= $today) AND (sport = $sportID)
AND (homeID = $teamID OR awayID = $teamID)
ORDER BY gameDate DESC";
- 1 回答
- 0 关注
- 190 浏览
添加回答
举报
0/150
提交
取消