这是我的代码:
$qry = "SELECT *
FROM parties
WHERE schoolid = $schoolid AND
WHERE timestart BETWEEN '$dateStart 00:00:00' AND '$dateEnd 23:59:59'
ORDER BY timestart, attending";
这是我在回复查询时得到的结果:
SELECT *
FROM parties
WHERE schoolid = 100 AND
WHERE timestart BETWEEN '2013-08-13 00:00:00' AND '2013-09-12 23:59:59'
ORDER BY timestart, attending
它不起作用。当我在PHPMyAdmin中手动运行代码时,它只是告诉我语法中有错误。有什么问题?
答案 0 :(得分:1)
SELECT *
FROM parties
WHERE schoolid = 100 AND
timestart BETWEEN '2013-08-13 00:00:00' AND '2013-09-12 23:59:59'
ORDER BY timestart, attending
删除 AND WHERE
,这在语法上是不正确的 - 正确的是 AND
在该位置。
答案 1 :(得分:1)
您输入WHERE
两次,而且必须只输入一次。
应该是这样的:
SELECT *
FROM parties
WHERE schoolid = 100 AND
timestart BETWEEN '2013-08-13 00:00:00' AND '2013-09-12 23:59:59'
ORDER BY timestart,attending
答案 2 :(得分:0)
除非使用子查询,否则查询中应该只有一个WHERE。