我对正在发生的事情感到困惑。所以我只需要一些想法或澄清。
我有3个PHP变量和两个PostgreSQL查询:
$date_start = $d1 = "2013-01-01";
$date_end = $d2 = "2013-01-05";
$car = "x";
$query_1 = pg_query($con, "SELECT AVG(longitude) as lon, AVG(latitude) as lat, MAX(longitude) as maxlon, MIN(longitude) as minlon, MAX(latitude) as maxlat, MIN(latitude) as minlat FROM table WHERE car='".$car."' AND testdate>='".$date_start."' AND testdate<='".$date_end."'";
$query_2 = pg_query($con, "SELECT MIN(testtime) as t1, MAX(testtime) as t2 FROM table WHERE car='$car' AND testdate>='$d1' AND testdate=<'$d2' GROUP BY testdate");
这里遇到的麻烦是$ query_1很好地为我提供了一个合适的结果资源,而另一个总是假的,并带有错误信息:
ERROR: operator does not exist: date =< unknown
LINE 1: ... car='BM1' AND testdate>='2013-04-04' AND testdate=<'2013-04...
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
那么......任何想法在那里发生了什么?我确信查询几乎是一样的,但是由于我不明白PostgreSQL抱怨一个而不是另一个!
我不需要有关如何解决此问题的帮助,我只需要知道原因。为什么行为不同......
干杯!!
此致 安迪
答案 0 :(得分:1)
我不是背叛专家,但AFAIK没有 =&lt; 操作符,但&lt; =
$query_2 = pg_query($con, "SELECT MIN(testtime) as t1, MAX(testtime) as t2 FROM table WHERE car='$car' AND testdate>='$d1' AND testdate=<'$d2' GROUP BY testdate");